From b5af308b9daa4d3839e21aa9aa9ed0d7c3620fed Mon Sep 17 00:00:00 2001 From: Mitchell Rysavy Date: Tue, 26 Nov 2024 02:49:39 +0000 Subject: [PATCH] Update sqlbuddy --- htdocs/sqlbuddy/LICENSE | 36 +- htdocs/sqlbuddy/README.md | 68 + htdocs/sqlbuddy/ajaxcreatetable.php | 72 +- htdocs/sqlbuddy/ajaxfulltext.php | 126 +- htdocs/sqlbuddy/ajaximportfile.php | 338 +-- htdocs/sqlbuddy/ajaxquery.php | 72 +- htdocs/sqlbuddy/ajaxsavecolumnedit.php | 74 +- htdocs/sqlbuddy/ajaxsaveedit.php | 256 +- htdocs/sqlbuddy/ajaxsaveuseredit.php | 258 +- htdocs/sqlbuddy/browse.php | 138 +- htdocs/sqlbuddy/config.php | 126 +- htdocs/sqlbuddy/css/common.css | 1774 ++++++------ htdocs/sqlbuddy/css/navigation.css | 186 +- htdocs/sqlbuddy/css/print.css | 52 +- htdocs/sqlbuddy/dboverview.php | 1153 ++++---- htdocs/sqlbuddy/edit.php | 418 +-- htdocs/sqlbuddy/editcolumn.php | 376 +-- htdocs/sqlbuddy/edituser.php | 506 ++-- htdocs/sqlbuddy/export.php | 1352 ++++----- htdocs/sqlbuddy/functions.php | 1125 ++++---- htdocs/sqlbuddy/home.php | 620 ++--- htdocs/sqlbuddy/import.php | 174 +- htdocs/sqlbuddy/includes/browse.php | 802 +++--- .../sqlbuddy/includes/class/GetTextReader.php | 154 +- htdocs/sqlbuddy/includes/class/Sql-php4.php | 846 +++--- htdocs/sqlbuddy/includes/class/Sql.php | 998 +++---- htdocs/sqlbuddy/includes/types.php | 158 +- htdocs/sqlbuddy/index.php | 42 +- htdocs/sqlbuddy/insert.php | 496 ++-- htdocs/sqlbuddy/js/core.js | 1676 +++++------ htdocs/sqlbuddy/js/helpers.js | 2478 ++++++++--------- htdocs/sqlbuddy/js/mootools-1.2-core.js | 482 ++-- htdocs/sqlbuddy/js/movement.js | 410 +-- htdocs/sqlbuddy/locale/ar_DZ.pot | 1331 ++++----- htdocs/sqlbuddy/locale/bg_BG.pot | 667 +++++ htdocs/sqlbuddy/locale/bn_BD.pot | 667 +++++ htdocs/sqlbuddy/locale/ca_AD.pot | 1331 ++++----- htdocs/sqlbuddy/locale/cs_CZ.pot | 1331 ++++----- htdocs/sqlbuddy/locale/da_DK.pot | 1331 ++++----- htdocs/sqlbuddy/locale/de_DE.pot | 1331 ++++----- htdocs/sqlbuddy/locale/el_GR.pot | 667 +++++ htdocs/sqlbuddy/locale/en_US.pot | 1329 ++++----- htdocs/sqlbuddy/locale/eo_EO.pot | 1331 ++++----- htdocs/sqlbuddy/locale/es_AR.pot | 1331 ++++----- htdocs/sqlbuddy/locale/es_ES.pot | 1331 ++++----- htdocs/sqlbuddy/locale/et_EE.pot | 667 +++++ htdocs/sqlbuddy/locale/fa_IR.pot | 1331 ++++----- htdocs/sqlbuddy/locale/fi_FI.pot | 1331 ++++----- htdocs/sqlbuddy/locale/fr_FR.pot | 1331 ++++----- htdocs/sqlbuddy/locale/gl_ES.pot | 1331 ++++----- htdocs/sqlbuddy/locale/he_IL.pot | 1331 ++++----- htdocs/sqlbuddy/locale/hr_HR.pot | 667 +++++ htdocs/sqlbuddy/locale/hu_HU.pot | 1331 ++++----- htdocs/sqlbuddy/locale/id_ID.pot | 1331 ++++----- htdocs/sqlbuddy/locale/it_IT.pot | 1331 ++++----- htdocs/sqlbuddy/locale/ja_JP.pot | 1331 ++++----- htdocs/sqlbuddy/locale/ko_KR.pot | 667 +++++ htdocs/sqlbuddy/locale/lo_LA.pot | 1331 ++++----- htdocs/sqlbuddy/locale/lt_LT.pot | 667 +++++ htdocs/sqlbuddy/locale/lv_LV.pot | 1331 ++++----- htdocs/sqlbuddy/locale/ms_ID.pot | 1331 ++++----- htdocs/sqlbuddy/locale/nl_NL.pot | 1333 ++++----- htdocs/sqlbuddy/locale/no_NO.pot | 667 +++++ htdocs/sqlbuddy/locale/pl_PL.pot | 1331 ++++----- htdocs/sqlbuddy/locale/pt_BR.pot | 1331 ++++----- htdocs/sqlbuddy/locale/pt_PT.pot | 1331 ++++----- htdocs/sqlbuddy/locale/ro_RO.pot | 1331 ++++----- htdocs/sqlbuddy/locale/ru_RU.pot | 1331 ++++----- htdocs/sqlbuddy/locale/sk_SK.pot | 1331 ++++----- htdocs/sqlbuddy/locale/sl_SL.pot | 1331 ++++----- htdocs/sqlbuddy/locale/sp_RS.pot | 1334 ++++----- htdocs/sqlbuddy/locale/sq_AL.pot | 668 +++++ htdocs/sqlbuddy/locale/sr_RS.pot | 1331 ++++----- htdocs/sqlbuddy/locale/sv_SE.pot | 1331 ++++----- htdocs/sqlbuddy/locale/th_TH.pot | 667 +++++ htdocs/sqlbuddy/locale/tl_PH.pot | 1331 ++++----- htdocs/sqlbuddy/locale/tr_TR.pot | 1331 ++++----- htdocs/sqlbuddy/locale/uk_UA.pot | 1331 ++++----- htdocs/sqlbuddy/locale/vi_VN.pot | 1331 ++++----- htdocs/sqlbuddy/locale/zh_CN.pot | 1331 ++++----- htdocs/sqlbuddy/locale/zh_TW.pot | 1331 ++++----- htdocs/sqlbuddy/login.php | 532 ++-- htdocs/sqlbuddy/logout.php | 80 +- htdocs/sqlbuddy/query.php | 154 +- htdocs/sqlbuddy/serve.php | 230 +- htdocs/sqlbuddy/structure.php | 1548 +++++----- htdocs/sqlbuddy/themes/bittersweet/css/ie.css | 86 +- .../sqlbuddy/themes/bittersweet/css/main.css | 308 +- htdocs/sqlbuddy/themes/classic/css/ie.css | 60 +- htdocs/sqlbuddy/themes/classic/css/main.css | 220 +- htdocs/sqlbuddy/users.php | 878 +++--- 91 files changed, 43027 insertions(+), 36163 deletions(-) create mode 100644 htdocs/sqlbuddy/README.md create mode 100644 htdocs/sqlbuddy/locale/bg_BG.pot create mode 100644 htdocs/sqlbuddy/locale/bn_BD.pot create mode 100644 htdocs/sqlbuddy/locale/el_GR.pot create mode 100644 htdocs/sqlbuddy/locale/et_EE.pot create mode 100644 htdocs/sqlbuddy/locale/hr_HR.pot create mode 100644 htdocs/sqlbuddy/locale/ko_KR.pot create mode 100644 htdocs/sqlbuddy/locale/lt_LT.pot create mode 100644 htdocs/sqlbuddy/locale/no_NO.pot create mode 100644 htdocs/sqlbuddy/locale/sq_AL.pot create mode 100644 htdocs/sqlbuddy/locale/th_TH.pot diff --git a/htdocs/sqlbuddy/LICENSE b/htdocs/sqlbuddy/LICENSE index c999e6d2c..69acd93f3 100755 --- a/htdocs/sqlbuddy/LICENSE +++ b/htdocs/sqlbuddy/LICENSE @@ -1,19 +1,19 @@ -Copyright (c) 2008 Calvin Lough - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +Copyright (c) 2008 Calvin Lough + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/htdocs/sqlbuddy/README.md b/htdocs/sqlbuddy/README.md new file mode 100644 index 000000000..0a5c49159 --- /dev/null +++ b/htdocs/sqlbuddy/README.md @@ -0,0 +1,68 @@ +| :warning:   SQL Buddy is no longer actively maintained. | +|-------------------------------------------------------------------| + +This software is still free to use under the license provided below, but users should be aware +that it is not currently maintained. No additional releases, including security releases, will +be made available. Caveat emptor. + + +SQL Buddy +=========== + +SQL Buddy is a phpMyAdmin alternative with a focus on usability. + +![Screenshot 1](https://raw.github.com/calvinlough/sqlbuddy/gh-pages/images/screenshot1.png) +![Screenshot 2](https://raw.github.com/calvinlough/sqlbuddy/gh-pages/images/screenshot2.png) +![Screenshot 3](https://raw.github.com/calvinlough/sqlbuddy/gh-pages/images/screenshot3.png) + +## Features + +* Create and drop databases and tables +* View, edit, insert and delete table rows +* Execute custom SQL and view the output +* Import and export databases and tables to SQL and CSV formats +* Add, edit and delete MySQL users +* Ships with 47 translations (including Esperanto!) + +## Download + +**[Download v1.3.3](https://github.com/calvinlough/sqlbuddy/raw/gh-pages/sqlbuddy.zip)** + +## Installation + +* Download the file above and unzip it +* Upload the sqlbuddy folder to your web server +* Point your browser to the sqlbuddy folder +* Log in using your existing MySQL credentials + +## Requirements + +* PHP 4.3+ +* MySQL 4+ + +## Help + +If you need help, a forum is available at http://groups.google.com/group/sql-buddy/topics + +## License + +Copyright © 2013 Calvin Lough + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/htdocs/sqlbuddy/ajaxcreatetable.php b/htdocs/sqlbuddy/ajaxcreatetable.php index 12f6ffb3a..b2809fe90 100755 --- a/htdocs/sqlbuddy/ajaxcreatetable.php +++ b/htdocs/sqlbuddy/ajaxcreatetable.php @@ -1,37 +1,37 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($_POST['query'])) { - - $queryList = splitQueryText($_POST['query']); - - foreach ($queryList as $query) { - $sql = $conn->query($query) or ($dbError = $conn->error()); - } - - if (isset($dbError)) { - echo $dbError; - } - -} - + + +*/ + +include "functions.php"; + +loginCheck(); + +if (isset($db)) + $conn->selectDB($db); + +if (isset($_POST['query'])) { + + $queryList = splitQueryText($_POST['query']); + + foreach ($queryList as $query) { + $sql = $conn->query($query) or ($dbError = $conn->error()); + } + + if (isset($dbError)) { + echo $dbError; + } + +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/ajaxfulltext.php b/htdocs/sqlbuddy/ajaxfulltext.php index eedebbeac..4a18b3195 100755 --- a/htdocs/sqlbuddy/ajaxfulltext.php +++ b/htdocs/sqlbuddy/ajaxfulltext.php @@ -1,64 +1,64 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($_POST['query'])) { - - $queryList = splitQueryText($_POST['query']); - - foreach ($queryList as $query) { - $sql = $conn->query($query); - } -} - -if ($conn->getAdapter() == "mysql") { - $structureSql = $conn->describeTable($table); - - while ($structureRow = $conn->fetchAssoc($structureSql)) { - $types[$structureRow['Field']] = $structureRow['Type']; - } -} - -if ($conn->isResultSet($sql)) { - - $row = $conn->fetchAssoc($sql); - - foreach ($row as $key => $value) { - echo "
" . $key . "
"; - echo "
"; - - $curtype = $types[$key]; - - if (strpos(" ", $curtype) > 0) { - $curtype = substr($curtype, 0, strpos(" ", $curtype)); - } - - if ($value && isset($binaryDTs) && in_array($curtype, $binaryDTs)) { - echo '(' . __("binary data") . ')'; - } else { - echo nl2br(htmlentities($value, ENT_QUOTES, 'UTF-8')); - } - - echo "
"; - } -} - + + +*/ + +include "functions.php"; + +loginCheck(); + +if (isset($db)) + $conn->selectDB($db); + +if (isset($_POST['query'])) { + + $queryList = splitQueryText($_POST['query']); + + foreach ($queryList as $query) { + $sql = $conn->query($query); + } +} + +if ($conn->getAdapter() == "mysql") { + $structureSql = $conn->describeTable($table); + + while ($structureRow = $conn->fetchAssoc($structureSql)) { + $types[$structureRow['Field']] = $structureRow['Type']; + } +} + +if ($conn->isResultSet($sql)) { + + $row = $conn->fetchAssoc($sql); + + foreach ($row as $key => $value) { + echo "
" . $key . "
"; + echo "
"; + + $curtype = $types[$key]; + + if (strpos(" ", $curtype) > 0) { + $curtype = substr($curtype, 0, strpos(" ", $curtype)); + } + + if ($value && isset($binaryDTs) && in_array($curtype, $binaryDTs)) { + echo '(' . __("binary data") . ')'; + } else { + echo nl2br(htmlentities($value, ENT_QUOTES, 'UTF-8')); + } + + echo "
"; + } +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/ajaximportfile.php b/htdocs/sqlbuddy/ajaximportfile.php index 816fefeb3..7171d6c27 100755 --- a/htdocs/sqlbuddy/ajaximportfile.php +++ b/htdocs/sqlbuddy/ajaximportfile.php @@ -1,170 +1,170 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if (isset($db)) - $conn->selectDB($db); - -function stripCommentLines($in) { - if (substr($in, 0, 2) == "--") - $in = ''; - - return $in; -} - -if (isset($_POST) || isset($_FILES)) { - - if (isset($_FILES['INPUTFILE']['tmp_name'])) - $file = $_FILES['INPUTFILE']['tmp_name']; - - if (isset($_POST['FORMAT'])) - $format = $_POST['FORMAT']; - - if (!(isset($format) && $format == "CSV")) - $format = "SQL"; - - if (isset($_POST['IGNOREFIRST'])) - $ignoreFirst = $_POST['IGNOREFIRST']; - - $first = true; - - // for csv - if (isset($format) && $format == "CSV" && isset($table)) { - $columnCount = 0; - - $structureSQL = $conn->describeTable($table); - - if ($conn->isResultSet($structureSQL)) { - while ($structureRow = $conn->fetchAssoc($structureSQL)) { - $columnCount++; - } - } - } - - $insertCount = 0; - $skipCount = 0; - - if (isset($file) && is_uploaded_file($file)) { - if (isset($format) && $format == "SQL") { - $lines = file($file); - - // the file() function doesn't handle mac line endings correctly - if (sizeof($lines) == 1 && strpos($lines[0], "\r") > 0) { - $lines = explode("\r", $lines[0]); - } - - $commentFree = array_map("stripCommentLines", $lines); - - $contents = trim(implode('', $commentFree)); - - $statements = splitQueryText($contents); - } else { - $statements = file($file); - - // see previous comment - if (sizeof($statements) == 1 && strpos($statements[0], "\r") > 0) { - $statements = explode("\r", $statements[0]); - } - } - - foreach ($statements as $statement) { - $statement = trim($statement); - - if ($statement) { - if (isset($format) && $format == "SQL") { - $importQuery = $conn->query($statement) or ($dbErrors[] = $conn->error()); - - $affected = (int)($conn->affectedRows($importQuery)); - $insertCount += $affected; - } else if (isset($format) && $format == "CSV" && isset($table)) { - if (!(isset($ignoreFirst) && $first)) { - preg_match_all('/"(([^"]|"")*)"/i', $statement, $matches); - - $rawValues = $matches[1]; - - for ($i=0; $iescapeString($rawValues[$i]); - } - - $values = implode("','", $rawValues); - - // make sure that the counts match up - if (sizeof($rawValues) == $columnCount) { - - if ($conn->getAdapter() == "sqlite") - $importQuery = $conn->query("INSERT INTO '$table' VALUES ('$values')") or ($dbErrors[] = $conn->error()); - else - $importQuery = $conn->query("INSERT INTO `$table` VALUES ('$values')") or ($dbErrors[] = $conn->error()); - - $affected = (int)($conn->affectedRows($importQuery)); - - $insertCount += $affected; - } else { - $skipCount++; - } - } - $first = false; - } - } - } - } - - $message = ""; - - if (!isset($statements)) { - $message .= __("Either the file could not be read or it was empty") . "
"; - } else if ($format == "SQL") { - $message .= sprintf(__p("%d statement was executed from the file", "%d statements were executed from the file", $insertCount), $insertCount) . ".
"; - } else if ($format == "CSV") { - if (isset($insertCount) && $insertCount > 0) { - $message .= sprintf(__p("%d row was inserted into the database from the file", "%d rows were inserted into the database from the file", $insertCount), $insertCount) . ".
"; - } - if (isset($skipCount) && $skipCount > 0) { - $message .= sprintf(__p("%d row had to be skipped because the number of values was incorrect", "%d rows had to be skipped because the number of values was incorrect", $skipCount), $skipCount) . ".
"; - } - } - - if (isset($dbErrors)) { - $message .= __("The following errors were reported") . ":
"; - foreach ($dbErrors as $merr) { - $message .= " - " . $merr . "
"; - } - } - - ?> - - - - - - - - - - + +*/ + +include "functions.php"; + +loginCheck(); + +if (isset($db)) + $conn->selectDB($db); + +function stripCommentLines($in) { + if (substr($in, 0, 2) == "--") + $in = ''; + + return $in; +} + +if (isset($_POST) || isset($_FILES)) { + + if (isset($_FILES['INPUTFILE']['tmp_name'])) + $file = $_FILES['INPUTFILE']['tmp_name']; + + if (isset($_POST['FORMAT'])) + $format = $_POST['FORMAT']; + + if (!(isset($format) && $format == "CSV")) + $format = "SQL"; + + if (isset($_POST['IGNOREFIRST'])) + $ignoreFirst = $_POST['IGNOREFIRST']; + + $first = true; + + // for csv + if (isset($format) && $format == "CSV" && isset($table)) { + $columnCount = 0; + + $structureSQL = $conn->describeTable($table); + + if ($conn->isResultSet($structureSQL)) { + while ($structureRow = $conn->fetchAssoc($structureSQL)) { + $columnCount++; + } + } + } + + $insertCount = 0; + $skipCount = 0; + + if (isset($file) && is_uploaded_file($file)) { + if (isset($format) && $format == "SQL") { + $lines = file($file); + + // the file() function doesn't handle mac line endings correctly + if (sizeof($lines) == 1 && strpos($lines[0], "\r") > 0) { + $lines = explode("\r", $lines[0]); + } + + $commentFree = array_map("stripCommentLines", $lines); + + $contents = trim(implode('', $commentFree)); + + $statements = splitQueryText($contents); + } else { + $statements = file($file); + + // see previous comment + if (sizeof($statements) == 1 && strpos($statements[0], "\r") > 0) { + $statements = explode("\r", $statements[0]); + } + } + + foreach ($statements as $statement) { + $statement = trim($statement); + + if ($statement) { + if (isset($format) && $format == "SQL") { + $importQuery = $conn->query($statement) or ($dbErrors[] = $conn->error()); + + $affected = (int)($conn->affectedRows($importQuery)); + $insertCount += $affected; + } else if (isset($format) && $format == "CSV" && isset($table)) { + if (!(isset($ignoreFirst) && $first)) { + preg_match_all('/"(([^"]|"")*)"/i', $statement, $matches); + + $rawValues = $matches[1]; + + for ($i=0; $iescapeString($rawValues[$i]); + } + + $values = implode("','", $rawValues); + + // make sure that the counts match up + if (sizeof($rawValues) == $columnCount) { + + if ($conn->getAdapter() == "sqlite") + $importQuery = $conn->query("INSERT INTO '$table' VALUES ('$values')") or ($dbErrors[] = $conn->error()); + else + $importQuery = $conn->query("INSERT INTO `$table` VALUES ('$values')") or ($dbErrors[] = $conn->error()); + + $affected = (int)($conn->affectedRows($importQuery)); + + $insertCount += $affected; + } else { + $skipCount++; + } + } + $first = false; + } + } + } + } + + $message = ""; + + if (!isset($statements)) { + $message .= __("Either the file could not be read or it was empty") . "
"; + } else if ($format == "SQL") { + $message .= sprintf(__p("%d statement was executed from the file", "%d statements were executed from the file", $insertCount), $insertCount) . ".
"; + } else if ($format == "CSV") { + if (isset($insertCount) && $insertCount > 0) { + $message .= sprintf(__p("%d row was inserted into the database from the file", "%d rows were inserted into the database from the file", $insertCount), $insertCount) . ".
"; + } + if (isset($skipCount) && $skipCount > 0) { + $message .= sprintf(__p("%d row had to be skipped because the number of values was incorrect", "%d rows had to be skipped because the number of values was incorrect", $skipCount), $skipCount) . ".
"; + } + } + + if (isset($dbErrors)) { + $message .= __("The following errors were reported") . ":
"; + foreach ($dbErrors as $merr) { + $message .= " - " . $merr . "
"; + } + } + + ?> + + + + + + + + + + \ No newline at end of file diff --git a/htdocs/sqlbuddy/ajaxquery.php b/htdocs/sqlbuddy/ajaxquery.php index 23ced5703..f318eb916 100755 --- a/htdocs/sqlbuddy/ajaxquery.php +++ b/htdocs/sqlbuddy/ajaxquery.php @@ -1,37 +1,37 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($_POST['query'])) { - $queryList = splitQueryText($_POST['query']); - - foreach ($queryList as $query) { - $sql = $conn->query($query); - } -} - -//return the first field from the first row -if (!isset($_POST['silent']) && $conn->isResultSet($sql)) { - $row = $conn->fetchArray($sql); - echo nl2br(htmlentities($row[0], ENT_QUOTES, 'UTF-8')); -} - + + +*/ + +include "functions.php"; + +loginCheck(); + +if (isset($db)) + $conn->selectDB($db); + +if (isset($_POST['query'])) { + $queryList = splitQueryText($_POST['query']); + + foreach ($queryList as $query) { + $sql = $conn->query($query); + } +} + +//return the first field from the first row +if (!isset($_POST['silent']) && $conn->isResultSet($sql)) { + $row = $conn->fetchArray($sql); + echo nl2br(htmlentities($row[0], ENT_QUOTES, 'UTF-8')); +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/ajaxsavecolumnedit.php b/htdocs/sqlbuddy/ajaxsavecolumnedit.php index 42a688c55..4b50dfe51 100755 --- a/htdocs/sqlbuddy/ajaxsavecolumnedit.php +++ b/htdocs/sqlbuddy/ajaxsavecolumnedit.php @@ -1,38 +1,38 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($_POST['runQuery'])) { - $query = $_POST['runQuery']; - - $conn->query($query) or ($dbError = $conn->error()); - - echo "{\n"; - echo " \"formupdate\": \"" . $_GET['form'] . "\",\n"; - echo " \"errormess\": \""; - if (isset($dbError)) - echo $dbError; - echo "\"\n"; - echo '}'; - -} - + + +*/ + +include "functions.php"; + +loginCheck(); + +if (isset($db)) + $conn->selectDB($db); + +if (isset($_POST['runQuery'])) { + $query = $_POST['runQuery']; + + $conn->query($query) or ($dbError = $conn->error()); + + echo "{\n"; + echo " \"formupdate\": \"" . $_GET['form'] . "\",\n"; + echo " \"errormess\": \""; + if (isset($dbError)) + echo $dbError; + echo "\"\n"; + echo '}'; + +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/ajaxsaveedit.php b/htdocs/sqlbuddy/ajaxsaveedit.php index 0af82d31f..632e61d1c 100755 --- a/htdocs/sqlbuddy/ajaxsaveedit.php +++ b/htdocs/sqlbuddy/ajaxsaveedit.php @@ -1,130 +1,128 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if (isset($db)) - $conn->selectDB($db); - -if ($_POST && isset($table)) { - - $insertChoice = ""; - - if (isset($_POST['SB_INSERT_CHOICE'])) { - $insertChoice = $_POST['SB_INSERT_CHOICE']; - } - - $structureSql = $conn->describeTable($table); - - if ($conn->getAdapter() == "mysql") { - while ($structureRow = $conn->fetchAssoc($structureSql)) { - $pairs[$structureRow['Field']] = ''; - $types[$structureRow['Field']] = $structureRow['Type']; - $nulls[$structureRow['Field']] = (isset($structureRow['Null'])) ? $structureRow['Null'] : "YES"; - } - } else if ($conn->getAdapter() == "sqlite") { - foreach ($structureRow as $column) { - $pairs[$column[0]] = ''; - } - } - - foreach ($_POST as $key=>$value) { - if ($key != "SB_INSERT_CHOICE") { - if (is_array($value)) { - $value = implode(",", $value); - } - - $pairs[$key] = $conn->escapeString($value); - } - } - - if (isset($pairs)) { - - if ($insertChoice != "INSERT") { - $updates = ""; - - foreach ($pairs as $keyname=>$value) { - if ($conn->getAdapter() == "mysql") { - if (isset($types) && substr($value, 0, 2) == "0x" && isset($binaryDTs) && in_array($types[$keyname], $binaryDTs)) { - $updates .= "`" . $keyname . "`=" . $value . ","; - } else if (!$value && $nulls[$keyname] == "YES") { - $updates .= "`" . $keyname . "`=NULL,"; - } else { - $updates .= "`" . $keyname . "`='" . $value . "',"; - } - } else if ($conn->getAdapter() == "sqlite") { - $updates .= "'" . $keyname . "'='" . $value . "',"; - } - } - - $updates = substr($updates, 0, -1); - - if (isset($_GET['queryPart'])) - $queryPart = $_GET['queryPart']; - else - $queryPart = ""; - - if ($conn->getAdapter() == "mysql") { - $query = "UPDATE `$table` SET " . $updates . " " . $queryPart; - } else if ($conn->getAdapter() == "sqlite") { - $query = "UPDATE '$table' SET " . $updates . " " . $queryPart; - } - - } else { - $columns = ""; - $values = ""; - - foreach ($pairs as $keyname=>$value) { - - if ($conn->getAdapter() == "mysql") { - $columns .= "`" . $keyname . "`,"; - } else if ($conn->getAdapter() == "sqlite") { - $columns .= "'" . $keyname . "',"; - } - - if (isset($types) && substr($value, 0, 2) == "0x" && isset($binaryDTs) && in_array($types[$keyname], $binaryDTs)) { - $values .= $value . ","; - } else { - $values .= "'" . $value . "',"; - } - - } - - $columns = substr($columns, 0, -1); - $values = substr($values, 0, -1); - - if ($conn->getAdapter() == "mysql") { - $query = "INSERT INTO `$table` ($columns) VALUES ($values)"; - } else if ($conn->getAdapter() == "sqlite") { - $query = "INSERT INTO '$table' ($columns) VALUES ($values)"; - } - } - - $conn->query($query) or ($dbError = $conn->error()); - - echo "{\n"; - echo " \"formupdate\": \"" . $_GET['form'] . "\",\n"; - echo " \"errormess\": \""; - if (isset($dbError)) - echo $dbError; - echo "\"\n"; - echo '}'; - - } -} - + + +*/ + +include "functions.php"; + +loginCheck(); + +if (isset($db)) + $conn->selectDB($db); + +if ($_POST && isset($table)) { + + $insertChoice = ""; + + if (isset($_POST['SB_INSERT_CHOICE'])) { + $insertChoice = $_POST['SB_INSERT_CHOICE']; + } + + $structureSql = $conn->describeTable($table); + + if ($conn->getAdapter() == "mysql") { + while ($structureRow = $conn->fetchAssoc($structureSql)) { + $pairs[$structureRow['Field']] = ''; + $types[$structureRow['Field']] = $structureRow['Type']; + $nulls[$structureRow['Field']] = (isset($structureRow['Null'])) ? $structureRow['Null'] : "YES"; + } + } else if ($conn->getAdapter() == "sqlite") { + foreach ($structureRow as $column) { + $pairs[$column[0]] = ''; + } + } + + foreach ($_POST as $key=>$value) { + if ($key != "SB_INSERT_CHOICE") { + if (is_array($value)) { + $value = implode(",", $value); + } + + $pairs[$key] = $conn->escapeString($value); + } + } + + if (isset($pairs)) { + + if ($insertChoice != "INSERT") { + $updates = ""; + + foreach ($pairs as $keyname=>$value) { + if ($conn->getAdapter() == "mysql") { + if (isset($types) && substr($value, 0, 2) == "0x" && isset($binaryDTs) && in_array($types[$keyname], $binaryDTs)) { + $updates .= "`" . $keyname . "`=" . $value . ","; + } else if (!$value && !($value != '' && (int)$value == 0) && $nulls[$keyname] == "YES") { + $updates .= "`" . $keyname . "`=NULL,"; + } else { + $updates .= "`" . $keyname . "`='" . $value . "',"; + } + } + } + + $updates = substr($updates, 0, -1); + + if (isset($_GET['queryPart'])) + $queryPart = $_GET['queryPart']; + else + $queryPart = ""; + + if ($conn->getAdapter() == "mysql") { + $query = "UPDATE `$table` SET " . $updates . " " . $queryPart; + } else if ($conn->getAdapter() == "sqlite") { + $query = "UPDATE '$table' SET " . $updates . " " . $queryPart; + } + + } else { + $columns = ""; + $values = ""; + + foreach ($pairs as $keyname=>$value) { + + if ($conn->getAdapter() == "mysql") { + $columns .= "`" . $keyname . "`,"; + } else if ($conn->getAdapter() == "sqlite") { + $columns .= "'" . $keyname . "',"; + } + + if (isset($types) && substr($value, 0, 2) == "0x" && isset($binaryDTs) && in_array($types[$keyname], $binaryDTs)) { + $values .= $value . ","; + } else { + $values .= "'" . $value . "',"; + } + + } + + $columns = substr($columns, 0, -1); + $values = substr($values, 0, -1); + + if ($conn->getAdapter() == "mysql") { + $query = "INSERT INTO `$table` ($columns) VALUES ($values)"; + } else if ($conn->getAdapter() == "sqlite") { + $query = "INSERT INTO '$table' ($columns) VALUES ($values)"; + } + } + + $conn->query($query) or ($dbError = $conn->error()); + + echo "{\n"; + echo " \"formupdate\": \"" . $_GET['form'] . "\",\n"; + echo " \"errormess\": \""; + if (isset($dbError)) + echo $dbError; + echo "\"\n"; + echo '}'; + + } +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/ajaxsaveuseredit.php b/htdocs/sqlbuddy/ajaxsaveuseredit.php index 76b024e0d..e56f2a98f 100755 --- a/htdocs/sqlbuddy/ajaxsaveuseredit.php +++ b/htdocs/sqlbuddy/ajaxsaveuseredit.php @@ -1,130 +1,130 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -$conn->selectDB("mysql"); - -function removeAdminPrivs($priv) { - if ($priv == "FILE" || $priv == "PROCESS" || $priv == "RELOAD" || $priv == "SHUTDOWN" || $priv == "SUPER") - return false; - else - return true; -} - -if (isset($_GET['user'])) - $user = $_GET['user']; - -if (isset($_POST['NEWPASS'])) - $newPass = $_POST['NEWPASS']; - -if (isset($_POST['CHOICE'])) - $choice = $_POST['CHOICE']; - -if (isset($_POST['ACCESSLEVEL'])) - $accessLevel = $_POST['ACCESSLEVEL']; -else - $accessLevel = "GLOBAL"; - -if ($accessLevel != "LIMITED") - $accessLevel = "GLOBAL"; - -if (isset($_POST['DBLIST'])) - $dbList = $_POST['DBLIST']; -else - $dbList = array(); - -if (isset($_POST['PRIVILEGES'])) - $privileges = $_POST['PRIVILEGES']; -else - $privileges = array(); - -if (isset($_POST['GRANTOPTION'])) - $grantOption = $_POST['GRANTOPTION']; - -if (isset($user) && ($accessLevel == "GLOBAL" || ($accessLevel == "LIMITED" && sizeof($dbList) > 0))) { - - if ($choice == "ALL") { - $privList = "ALL"; - } else { - if (isset($privileges) && count($privileges) > 0) - $privList = implode(", ", $privileges); - else - $privList = "USAGE"; - - if (sizeof($privileges) > 0) { - if ($accessLevel == "LIMITED") { - $privileges = array_filter($privileges, "removeAdminPrivs"); - } - - $privList = implode(", ", $privileges); - } else { - $privList = "USAGE"; - } - - } - - $split = explode("@", $user); - - if (isset($split[0])) - $name = $split[0]; - - if (isset($split[1])) - $host = $split[1]; - - if (isset($name) && isset($host)) { - $user = "'" . $name . "'@'" . $host . "'"; - - if ($accessLevel == "LIMITED") { - $conn->query("DELETE FROM `db` WHERE `User`='$name' AND `Host`='$host'"); - - foreach ($dbList as $theDb) { - $query = "GRANT " . $privList . " ON `$theDb`.* TO " . $user; - - if (isset($grantOption)) - $query .= " WITH GRANT OPTION"; - - $conn->query($query) or ($dbError = $conn->error()); - } - } else { - $conn->query("REVOKE ALL PRIVILEGES ON *.* FROM " . $user); - $conn->query("REVOKE GRANT OPTION ON *.* FROM " . $user); - - $query = "GRANT " . $privList . " ON *.* TO " . $user; - - if (isset($grantOption)) - $query .= " WITH GRANT OPTION"; - - $conn->query($query) or ($dbError = $conn->error()); - } - - if (isset($newPass)) - $conn->query("SET PASSWORD FOR '$name'@'$host' = PASSWORD('$newPass')") or ($dbError = $conn->error()); - - $conn->query("FLUSH PRIVILEGES") or ($dbError = $conn->error()); - - echo "{\n"; - echo " \"formupdate\": \"" . $_GET['form'] . "\",\n"; - echo " \"errormess\": \""; - if (isset($dbError)) - echo $dbError; - echo "\"\n"; - echo '}'; - } -} - + + +*/ + +include "functions.php"; + +loginCheck(); + +$conn->selectDB("mysql"); + +function removeAdminPrivs($priv) { + if ($priv == "FILE" || $priv == "PROCESS" || $priv == "RELOAD" || $priv == "SHUTDOWN" || $priv == "SUPER") + return false; + else + return true; +} + +if (isset($_GET['user'])) + $user = $_GET['user']; + +if (isset($_POST['NEWPASS'])) + $newPass = $_POST['NEWPASS']; + +if (isset($_POST['CHOICE'])) + $choice = $_POST['CHOICE']; + +if (isset($_POST['ACCESSLEVEL'])) + $accessLevel = $_POST['ACCESSLEVEL']; +else + $accessLevel = "GLOBAL"; + +if ($accessLevel != "LIMITED") + $accessLevel = "GLOBAL"; + +if (isset($_POST['DBLIST'])) + $dbList = $_POST['DBLIST']; +else + $dbList = array(); + +if (isset($_POST['PRIVILEGES'])) + $privileges = $_POST['PRIVILEGES']; +else + $privileges = array(); + +if (isset($_POST['GRANTOPTION'])) + $grantOption = $_POST['GRANTOPTION']; + +if (isset($user) && ($accessLevel == "GLOBAL" || ($accessLevel == "LIMITED" && sizeof($dbList) > 0))) { + + if ($choice == "ALL") { + $privList = "ALL"; + } else { + if (isset($privileges) && count($privileges) > 0) + $privList = implode(", ", $privileges); + else + $privList = "USAGE"; + + if (sizeof($privileges) > 0) { + if ($accessLevel == "LIMITED") { + $privileges = array_filter($privileges, "removeAdminPrivs"); + } + + $privList = implode(", ", $privileges); + } else { + $privList = "USAGE"; + } + + } + + $split = explode("@", $user); + + if (isset($split[0])) + $name = $split[0]; + + if (isset($split[1])) + $host = $split[1]; + + if (isset($name) && isset($host)) { + $user = "'" . $name . "'@'" . $host . "'"; + + if ($accessLevel == "LIMITED") { + $conn->query("DELETE FROM `db` WHERE `User`='$name' AND `Host`='$host'"); + + foreach ($dbList as $theDb) { + $query = "GRANT " . $privList . " ON `$theDb`.* TO " . $user; + + if (isset($grantOption)) + $query .= " WITH GRANT OPTION"; + + $conn->query($query) or ($dbError = $conn->error()); + } + } else { + $conn->query("REVOKE ALL PRIVILEGES ON *.* FROM " . $user); + $conn->query("REVOKE GRANT OPTION ON *.* FROM " . $user); + + $query = "GRANT " . $privList . " ON *.* TO " . $user; + + if (isset($grantOption)) + $query .= " WITH GRANT OPTION"; + + $conn->query($query) or ($dbError = $conn->error()); + } + + if (isset($newPass)) + $conn->query("SET PASSWORD FOR '$name'@'$host' = PASSWORD('$newPass')") or ($dbError = $conn->error()); + + $conn->query("FLUSH PRIVILEGES") or ($dbError = $conn->error()); + + echo "{\n"; + echo " \"formupdate\": \"" . $_GET['form'] . "\",\n"; + echo " \"errormess\": \""; + if (isset($dbError)) + echo $dbError; + echo "\"\n"; + echo '}'; + } +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/browse.php b/htdocs/sqlbuddy/browse.php index 99892b4d5..50e19e888 100755 --- a/htdocs/sqlbuddy/browse.php +++ b/htdocs/sqlbuddy/browse.php @@ -1,70 +1,70 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -requireDatabaseAndTableBeDefined(); - -if (isset($db)) - $conn->selectDB($db); - -//run delete queries - -if (isset($_POST['runQuery'])) { - $runQuery = $_POST['runQuery']; - - $queryList = splitQueryText($runQuery); - foreach ($queryList as $query) { - $conn->query($query); - } -} - -if ($conn->getAdapter() == "sqlite") { - $query = "SELECT * FROM '$table'"; -} else { - $query = "SELECT * FROM `$table`"; -} - -$queryTable = $table; - -if (isset($_POST['s'])) - $start = (int)($_POST['s']); -else - $start = 0; - -if (isset($_POST['sortKey'])) - $sortKey = $_POST['sortKey']; - -if (isset($_POST['sortDir'])) - $sortDir = $_POST['sortDir']; -else if (isset($sortKey)) - $sortDir = "ASC"; - -if (isset($_POST['view']) && $_POST['view'] == "1") - $view = 1; -else - $view = 0; - -if (isset($sortKey) && $sortKey != "" && isset($sortDir) && $sortDir != "") { - $sort = "ORDER BY `" . $sortKey . "` " . $sortDir; -} else { - $sort = ""; -} - -require "includes/browse.php"; - + + +*/ + +include "functions.php"; + +loginCheck(); + +requireDatabaseAndTableBeDefined(); + +if (isset($db)) + $conn->selectDB($db); + +//run delete queries + +if (isset($_POST['runQuery'])) { + $runQuery = $_POST['runQuery']; + + $queryList = splitQueryText($runQuery); + foreach ($queryList as $query) { + $conn->query($query); + } +} + +if ($conn->getAdapter() == "sqlite") { + $query = "SELECT * FROM '$table'"; +} else { + $query = "SELECT * FROM `$table`"; +} + +$queryTable = $table; + +if (isset($_POST['s'])) + $start = (int)($_POST['s']); +else + $start = 0; + +if (isset($_POST['sortKey'])) + $sortKey = $_POST['sortKey']; + +if (isset($_POST['sortDir'])) + $sortDir = $_POST['sortDir']; +else if (isset($sortKey)) + $sortDir = "ASC"; + +if (isset($_POST['view']) && $_POST['view'] == "1") + $view = 1; +else + $view = 0; + +if (isset($sortKey) && $sortKey != "" && isset($sortDir) && $sortDir != "") { + $sort = "ORDER BY `" . $sortKey . "` " . $sortDir; +} else { + $sort = ""; +} + +require "includes/browse.php"; + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/config.php b/htdocs/sqlbuddy/config.php index c36bfd620..986acb0b6 100755 --- a/htdocs/sqlbuddy/config.php +++ b/htdocs/sqlbuddy/config.php @@ -1,64 +1,64 @@ - - -*/ - - -/* The values below are for the login.php page */ - -$sbconfig['DefaultAdapter'] = "mysql"; -$sbconfig['DefaultHost'] = "localhost"; -$sbconfig['DefaultUser'] = "root"; - -/* -* If you want to enable automatic login, you can include your password below. To -* automatically connect to SQLite, include the filename of the database instead. -* Note: This is generally not recommended because it means that anyone with the -* proper url will have access to your data. It should only be used on machines -* that are not accessible from the internet (local testing boxes) or if you have -* set up some other form of authentication. Use as your own discretion. -*/ - -// MySQL -// $sbconfig['DefaultPass'] = ""; - -// SQLite -// $sbconfig['DefaultDatabase'] = ""; - -/* -* By default, when you view the homepage of your SQL Buddy installation, a check is -* performed to see if a newer version of the application is available. No personal -* information is sent about your installation and the response from the server is sent -* as plain text. If, for some reason, you want to disable this behaviour, set this option -* to true to disable automatic checking for updates. To learn about new versions, you can -* always check the projects website at http://www.sqlbuddy.com/ -*/ - -$sbconfig['EnableUpdateCheck'] = true; - -/* -* This controls how many rows are displayed at once on the browse tab. If you are on a local -* machine or have a fast internet connection, you could increase this value. -*/ - -$sbconfig['RowsPerPage'] = 100; - -/* -* When set to true, the server will attempt to compress all content before it is sent to the -* browser. Although unlikely, there is a chance that using gzip will cause issues on certain setups. -* If you are having trouble getting pages to load properly, you could try disabling gzip. -*/ - -$sbconfig['EnableGzip'] = true; - + + +*/ + + +/* The values below are for the login.php page */ + +$sbconfig['DefaultAdapter'] = "mysql"; +$sbconfig['DefaultHost'] = "localhost"; +$sbconfig['DefaultUser'] = "root"; + +/* +* If you want to enable automatic login, you can include your password below. To +* automatically connect to SQLite, include the filename of the database instead. +* Note: This is generally not recommended because it means that anyone with the +* proper url will have access to your data. It should only be used on machines +* that are not accessible from the internet (local testing boxes) or if you have +* set up some other form of authentication. Use as your own discretion. +*/ + +// MySQL +// $sbconfig['DefaultPass'] = ""; + +// SQLite +// $sbconfig['DefaultDatabase'] = ""; + +/* +* By default, when you view the homepage of your SQL Buddy installation, a check is +* performed to see if a newer version of the application is available. No personal +* information is sent about your installation and the response from the server is sent +* as plain text. If, for some reason, you want to disable this behaviour, set this option +* to true to disable automatic checking for updates. To learn about new versions, you can +* always check the projects website at http://www.sqlbuddy.com/ +*/ + +$sbconfig['EnableUpdateCheck'] = true; + +/* +* This controls how many rows are displayed at once on the browse tab. If you are on a local +* machine or have a fast internet connection, you could increase this value. +*/ + +$sbconfig['RowsPerPage'] = 100; + +/* +* When set to true, the server will attempt to compress all content before it is sent to the +* browser. Although unlikely, there is a chance that using gzip will cause issues on certain setups. +* If you are having trouble getting pages to load properly, you could try disabling gzip. +*/ + +$sbconfig['EnableGzip'] = true; + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/css/common.css b/htdocs/sqlbuddy/css/common.css index b6345d75a..bccc92a44 100755 --- a/htdocs/sqlbuddy/css/common.css +++ b/htdocs/sqlbuddy/css/common.css @@ -1,888 +1,888 @@ -body { -text-align: center; -background: url(../images/initLoad.png) no-repeat 50% 125px; -font: 12px/17px arial, sans-serif; -color: rgb(50, 50, 50); -} - -* { -margin: 0; padding: 0; -} - -table { -border-spacing: 0; -} - -a { -text-decoration: none; -color: #3A6D96; -cursor: pointer; -} -a:hover { -color: rgb(60, 60, 60); -} -a img { -border: 0; -display: block; -} - -p { -margin: 3px 0 5px; -} - -h3 { -font-size: 13px; -} -h4 { -font-size: 13px; -margin: 0 0 5px 0; -border-bottom: 1px solid rgb(220, 220, 220); -} - -ul { -padding-left: 20px; -} - -li { -list-style-type: square; -} - -input, textarea, select { -font-family: arial, sans-serif; -color: rgb(50, 50, 50); -} -.text, textarea { -padding: 1px; -font-size: 13px; -width: 175px; -} -textarea { -height: 80px; -line-height: 15px; -} -select { -font-size: 12px; -} -select[multiple] { -border-color: rgb(195, 195, 195) rgb(235, 235, 235) rgb(225, 225, 225) rgb(215, 215, 215); -border-width: 1px; -border-style: solid; -} -option { -padding: 1px 5px; -} -label { -margin: 0 5px 0 0; -vertical-align: middle; -} -label input { -margin: 0 5px 2px 0; -vertical-align: middle; -} -.inputbutton { -background: url(../images/button.png); -padding: 2px 5px 4px; -font-size: 12px; -line-height: 18px; -width: 60px; -height: 22px; -border: 0; -color: rgb(60, 60, 60); -outline-width: thin; -} -.inputbutton:active { -background: url(../images/button.png) 0 22px; -color: rgb(80, 80, 80); -} - -#headerlogo { -width: 161px; -padding: 10px 15px 2px; -float: left; -} -#headerlogo a { -outline: none; -} -#headerlogo img { -display: inline; -} -#headerinfo { -padding: 7px 18px 0; -width: 175px; -text-align: right; -float: right; -color: white; -} -#headerinfo a { -margin-left: 10px; -outline: none; -} - -#load { -color: rgb(190, 190, 190); -} - -#container { -width: 100%; -line-height: 18px; -text-align: left; -} - -#bottom { -width: 100%; -opacity: 0; -clear: left; -padding-top: 6px; -min-height: 350px; -} -#leftside { -vertical-align: top; -width: 180px; -float: left; -} -#rightside { -vertical-align: top; -margin-left: 180px; -padding: 0 6px 5px 0; -} -#sidemenu { -display: block; -padding: 10px 0 0 5px; -} - -#content { -width: 100%; -} -#innercontent { -padding: 8px 10px 10px; -} - -.grid { -border-width: 1px; -border-style: solid; -border-color: rgb(225, 225, 225) rgb(210, 210, 210) rgb(210, 210, 210) rgb(210, 210, 210); -background: url(../images/schemaHeader.png) top repeat-x; -} - -.gridheader { -height: 18px; -border-bottom: 1px solid rgb(150, 150, 150); -border-right: 1px solid #fff; -overflow: hidden; -} -.gridheaderinner { -padding-left: 1px; -} - -.headertitle { -background: #EEEEEE url(../images/schemaHeader.png) top; -padding: 0 5px 0 6px; -width: 200px; -cursor: pointer; -overflow: hidden; -display: block; -float: left; -color: rgb(90, 90, 90); -} - -.columnresizer { -border-right: 1px solid rgb(255, 255, 255); -border-left: 1px solid rgb(185, 185, 185); -width: 0; -height: 18px; -cursor: ew-resize; -} - -.emptyvoid { -background: #EEEEEE url(../images/schemaHeader.png) top; -height: 16px; -width: 14px; -padding: 1px 4px; -float: left; -border-bottom: 1px solid rgb(150, 150, 150); -border-right: 1px solid rgb(205, 205, 205); -} - -.impotent .headertitle, .impotent .columnresizer { -cursor: default; -} -.nosort .headertitle { -cursor: default; -} - -.browse { -line-height: 17px; -min-width: 100%; -width: 100%; -} -.browse table td { -border-right: 1px solid rgb(200, 200, 200); -vertical-align: top; -} - -.item { -padding: 2px 6px; -width: 200px; -overflow: hidden; -max-height: 16px; -} -.longtext { -width: 300px; -} -.numeric { -width: 150px; -} -.binary { -font-style: italic; -color: #AAAA8F; -} -.structure .headertitle, .structure .item, .dboverview .headertitle, .dboverview .item { -width: 150px; -} - -.leftchecks { -width: 22px; -position: absolute; -overflow: hidden; -border-right: 1px solid rgb(185, 185, 185); -} -.manip { -padding-top: 1px; -vertical-align: top; -height: 19px; -} -.manip:last-child { -border-bottom: 0 !important; -} -.manip dt { -width: 15px; -padding: 0 1px 0 5px; -float: left; -} -.manip dd { -width: 15px; -padding: 2px 0 0 0; -float: left; -} -.manip dd a { -background: url(../images/info.png) no-repeat; -width: 13px; -height: 13px; -display: block; -cursor: default; -} -.manip dd a:hover { -background: url(../images/infoHover.png) no-repeat; -} -.browsetab .leftchecks { -width: 38px; -} - -.withchecks { -margin-left: 22px; -border-left: 1px solid rgb(240, 240, 240); -} -.withinfo { -margin-left: 39px; -} - -.sort { -color: steelblue; -} -.sortasc { -background: url(../images/sortasc.gif) no-repeat right 6px; -margin-right: 1px; -} -.sortdesc { -background: url(../images/sortdesc.gif) no-repeat right 5px; -margin-right: 1px; -} - -.alternator { -border-bottom: 1px solid #f0f0ff; -} -.alternator2 { -background: #f0f0ff; -border-bottom: 1px solid transparent; -} -.highlighted { -background: #F5F5B8 !important; -border-bottom: 1px solid #E5E6AD !important; -} - -.gridscroll { -overflow: auto; -min-height: 21px; -} - -.gridscroll .browse:last-child { -border-bottom: 0 !important; -} - -.browsenav { -width: 100%; -padding: 2px 0 3px; -} -.browsenav td { -color: rgb(125, 125, 125); -} -.browsenav a { -outline: none; -} -.browsenav .options { -padding-left: 7px; -} -.browsenav .options a { -margin: 0 1px; -} -.browsenav .right { -padding-right: 8px; -text-align: right; -} -.browsenav .right a { -padding-left: 10px; -} -.browsenav .paginator { -padding: 0 3px 0 5px; -} -.browsenav .paginator a { -color: rgb(125, 125, 125); -padding-left: 5px; -} -.browsenav .paginator a.selected { -font-weight: bold; -color: rgb(150, 150, 150); -} - -.insert { -margin: 8px 6px; -width: 350px; -} -.insert td { -padding: 1px 6px 0; -} -.insert .inputarea { -padding-bottom: 8px; -} -.insert .text { -width: 325px; -} -.insert textarea { -width: 325px; -} -.insertseperator { -width: 348px; -margin: 12px 5px; -border-bottom: 2px solid #ccc; -} -.insertmessage { -margin: 1px 4px; -padding: 4px 8px; -color: rgb(75, 75, 75); -width: 332px; -} - -.edit { -border-bottom: 1px solid rgb(175, 175, 175); -margin-bottom: 17px; -} -form:last-child .edit { -border-bottom: 0 !important; -} - -.fieldheader { -color: rgb(110, 110, 110); -} -.fieldheader .fieldheadertitle { -width: 345px; -display: block; -float: left; -} -.fieldheader a.fieldclose { -width: 14px; -height: 16px; -padding-right: 4px; -display: block; -float: right; -background: url(../images/close.png) no-repeat 0 1px; -} -.fieldheader a.fieldclose:hover { -background: url(../images/closeHover.png) no-repeat 0 1px; -} -.secondaryheader { -color: rgb(100, 100, 100); -padding-right: 8px !important; -vertical-align: top; -} -.secondaryheader a { -color: rgb(100, 100, 100); -} - -#fieldlist .fieldbox:first-child .fieldclose { -display: none; -} - -.structure .inputbox { -width: 500px; -margin-top: 15px; -} -.structure .secondaryheader { -width: 65px; -} -.structure .grid { -margin-bottom: 15px; -} - -.columnheader { -color: rgb(125, 125, 125); -padding: 3px 0 0 7px; -cursor: pointer; -} -.column .text { -font-size: 12px; -} - -.paneheader { -margin: 7px 0 0; -color: rgb(115, 115, 115); -} -.paneheader a { -color: rgb(115, 115, 115); -} - -.dboverview .column1 { -width: 200px; -} -.dboverview .inputbox { -width: 500px; -} -.dboverview .inputbox .secondaryheader { -width: 80px; -} - -.overview { -margin: 0px 0 5px 0; -border-bottom: 1px solid rgb(220, 220, 220); -padding: 0 0 3px 0; -} -.inputbox .overview td { -padding: 7px 0 3px; -} -.overview .fieldheader { -border-bottom: 1px solid rgb(220, 220, 220); -padding-bottom: 2px; -} -.overview .text, .overview select, .overview option { -width: 135px; -} - -.editcolumn { -margin-left: 4px; -padding: 12px 0; -width: 430px; -} -.editcolumn table { -width: 100%; -} -.editcolumn td { -padding: 1px 6px 0; -} -.editcolumn .inputarea { -padding-bottom: 8px; -} -.editcolumn .text { -width: 325px; -font-size: 12px !important; -} - -.edituser { -margin: 0 0 4px 13px; -padding: 12px 0; -width: 335px; -border-bottom: 1px solid rgb(175, 175, 175); -} -form:last-child .edituser { -border-bottom: 0 !important; -} -.edituser .edit { -border-bottom: 0; -margin-bottom: 0; -} -.edituser .secondaryheader { -width: 110px; -} - -.users { -padding: 5px 7px 7px; -width: 550px; -} -.users .inputbox { -width: 335px; -} -.users .secondaryheader { -width: 110px; -} -.privpane { -background: rgb(240, 240, 240); -padding: 1px 0px 8px 12px; -margin-top: 5px; -} -#dbaccesspane { -padding-top: 5px !important; -} -.privpane td { -padding: 1px 0 !important; -} - -.export { -padding: 7px 7px 5px 14px; -width: 375px; -} -.export h4 { -padding-bottom: 3px; -} -.export .secondaryheader { -width: 110px; -} -.export .message { -color: rgb(100, 100, 100); -line-height: 14px; -} -.export table { -width: 100%; -} -.export td { -padding: 5px 0; -} -.export select { -width: 100%; -} -.export .text { -font-size: 12px; -width: 100px; -} -.exportseperator { -margin: 7px 0; -border-bottom: 1px solid rgb(210, 210, 210); -} -#EXPORTWRAPPER { -padding: 7px; -} -#EXPORTWRAPPER strong { -color: #646464; -} -#EXPORTRESULTS { -width: 100%; -max-width: 100%; -height: 250px; -font-size: 12px; -margin-top: 3px; -} - -.import { -padding: 7px 7px 5px 14px; -width: 350px; -} -.import h4 { -padding-bottom: 3px; -} -.import .secondaryheader { -width: 80px; -} -.import table { -width: 100%; -} -.import td { -padding: 5px 0; -} -.import .text { -font-size: 12px; -width: 100px; -} - -.inputbox { -padding: 0 7px 5px; -} -.inputbox h4 { -margin-bottom: 5px; -padding-bottom: 2px; -} -.inputbox table { -width: 100%; -} -.inputbox td { -padding: 5px 0; -} -.inputbox .text, .inputbox textarea, .inputbox select[multiple] { -font-size: 12px; -} - -.fulltextwin { -position: absolute; -text-align: left; -color: rgb(240, 240, 240); -width: 475px; -} -.fulltextheader { -height: 21px; -} -.fulltextheader td { -padding: 2px 0; -} -.headertl { -width: 19px; -background: url(../images/window-header-left.png) no-repeat; -} -.headertr { -width: 19px; -background: url(../images/window-header-right.png) no-repeat; -} -.headercenter { -background: url(../images/window-header-center.png) repeat-x; -} - -.fulltextheader p { -margin: 0 !important; -padding-left: 2px; -} -.fulltextheader img { -margin-top: 1px; -} -.mainl { -width: 13px; -background: url(../images/window-shadow-left.png) repeat-y; -} -.maincenter { -background: url(../images/window-center.png); -padding: 5px 5px 0 8px; -} -.fulltextcontent { -overflow: auto; -min-height: 100px; -padding-right: 5px; -} -.mainr { -width: 13px; -background: url(../images/window-shadow-right.png) repeat-y; -} -.fulltexttitle { -color: rgb(175, 175, 175); -font-weight: bold; -} -.fulltextbody { -margin-bottom: 10px; -line-height: 15px; -} -.fulltextfooter { -width: 100%; -} -.fulltextfooter td { -height: 19px; -} -.footerbl { -width: 15px; -background: url(../images/window-shadow-bottom-left.png) no-repeat -1px; -} -.footerbr { -width: 15px; -background: url(../images/window-shadow-bottom-right.png) no-repeat; -} -.footermiddle { -width: auto; -background: url(../images/window-shadow-bottom.png) repeat-x; -} - -.dialog { -width: 475px; -} -.dialog .fulltextcontent { -min-height: 25px; -} -.dialog .maincenter { -padding: 5px 2px 0px 8px !important -} -.buttons { -padding: 7px 0 5px; -} -.windowbutton { -background: url(../images/window-button.png); -padding: 3px 5px 4px; -width: 60px; -height: 22px; -border: 0; -color: white; -outline-color: rgb(130, 130, 130); -outline-width: thin; -} -.resizeHandle { -float: right; -margin-bottom: -1px; -} - -#QUERY { -width: 550px; -font-size: 12px; -display: block; -margin: 2px 0 0; -} - -.querybox { -font-family: "courier new"; -background: rgb(90, 90, 90); -padding: 4px 6px 2px; -margin: 10px 0 1px 0; -max-height: 75px; -overflow: auto; -font-weight: normal; -} - -.clearer { -height: 0; -line-height: 0; -clear: both; -} - -#loginform { -margin: 0 auto; -width: 330px; -margin-top: 115px; -} -#loginform .loginspacer { -padding: 13px 18px 13px 14px; -} -#loginform table { -width: 100%; -} -.loginheader { -border-bottom: 1px solid #E1E1E1; -padding-bottom: 8px !important; -float: left; -width: 100%; -margin-bottom: 10px; -} -.loginheader h3 { -font-size: 13px; -float: left; -} -.loginheader a { -float: right; -text-align: right; -} -#loginform td { -padding: 5px 5px; -line-height: 14px; -} -#loginform .field { -width: 85px; -text-align: right; -color: #4A7496; -} -#loginform select { -width: 165px; -} -#loginform .text { -width: 160px; -color: rgb(70, 70, 70); -font-size: 13px; -} -#loginform .errormess { -color: #AA3939; -padding: 0 0 5px; -text-align: center; -} - -.errormessage { -background: rgb(255, 245, 245); -border: 1px solid rgb(230, 210, 210); -padding: 7px 9px; -line-height: 15px; -color: rgb(80, 80, 80); -} -.errormessage strong { -color: #EB4A4A; -display: block; -margin-bottom: 3px; -} -.errormessage p { -margin-bottom: 0; -} -.statusmessage { -padding: 4px 0; -color: rgb(125, 125, 125); -} - -.hometable { -margin: 7px 0 0 10px; -width: 475px; -} -.hometable p { -line-height: 15px; -} -.hometable table td { -padding-top: 7px; -} -.hometable .text { -width: 130px; -} -.hometable select { -width: 135px; -} -.hometable .inputfield { -color: rgb(140, 140, 140); -width: 95px; -padding-right: 7px; -text-align: right; -} - -.keyboardtable { -width: 445px; -margin-top: 7px; -border-right: 1px solid rgb(200, 200, 200); -border-bottom: 1px solid rgb(200, 200, 200); -} -.keyboardtable td, .keyboardtable th { -padding: 1px 10px 1px 5px !important; -border-left: 1px solid rgb(200, 200, 200); -border-top: 1px solid rgb(200, 200, 200); -} -.keyboardtable th { -color: rgb(125, 125, 125); -font-weight: normal; -text-align: left; -} - -dl.information { -width: 200px; -} -dl.information dt { -float: left; -width: 100px; -clear: left; -color: rgb(125, 125, 125); -} -dl.information dd { -float: left; -width: 100px; -} - -.morelink:hover { -text-decoration: underline; -} - -.errorpage { -padding: 6px 10px 3px; -width: 450px; -} -.errorpage h4 { -font-weight: bold; -} - -.goto { -cursor: pointer; -margin-top: 2px; -opacity: 0.7; -float: right; -} -.goto:hover { -opacity: 1; +body { +text-align: center; +background: url(../images/initLoad.png) no-repeat 50% 125px; +font: 12px/17px arial, sans-serif; +color: rgb(50, 50, 50); +} + +* { +margin: 0; padding: 0; +} + +table { +border-spacing: 0; +} + +a { +text-decoration: none; +color: #3A6D96; +cursor: pointer; +} +a:hover { +color: rgb(60, 60, 60); +} +a img { +border: 0; +display: block; +} + +p { +margin: 3px 0 5px; +} + +h3 { +font-size: 13px; +} +h4 { +font-size: 13px; +margin: 0 0 5px 0; +border-bottom: 1px solid rgb(220, 220, 220); +} + +ul { +padding-left: 20px; +} + +li { +list-style-type: square; +} + +input, textarea, select { +font-family: arial, sans-serif; +color: rgb(50, 50, 50); +} +.text, textarea { +padding: 1px; +font-size: 13px; +width: 175px; +} +textarea { +height: 80px; +line-height: 15px; +} +select { +font-size: 12px; +} +select[multiple] { +border-color: rgb(195, 195, 195) rgb(235, 235, 235) rgb(225, 225, 225) rgb(215, 215, 215); +border-width: 1px; +border-style: solid; +} +option { +padding: 1px 5px; +} +label { +margin: 0 5px 0 0; +vertical-align: middle; +} +label input { +margin: 0 5px 2px 0; +vertical-align: middle; +} +.inputbutton { +background: url(../images/button.png); +padding: 2px 5px 4px; +font-size: 12px; +line-height: 18px; +width: 60px; +height: 22px; +border: 0; +color: rgb(60, 60, 60); +outline-width: thin; +} +.inputbutton:active { +background: url(../images/button.png) 0 22px; +color: rgb(80, 80, 80); +} + +#headerlogo { +width: 161px; +padding: 10px 15px 2px; +float: left; +} +#headerlogo a { +outline: none; +} +#headerlogo img { +display: inline; +} +#headerinfo { +padding: 7px 18px 0; +width: 175px; +text-align: right; +float: right; +color: white; +} +#headerinfo a { +margin-left: 10px; +outline: none; +} + +#load { +color: rgb(190, 190, 190); +} + +#container { +width: 100%; +line-height: 18px; +text-align: left; +} + +#bottom { +width: 100%; +opacity: 0; +clear: left; +padding-top: 6px; +min-height: 350px; +} +#leftside { +vertical-align: top; +width: 180px; +float: left; +} +#rightside { +vertical-align: top; +margin-left: 180px; +padding: 0 6px 5px 0; +} +#sidemenu { +display: block; +padding: 10px 0 0 5px; +} + +#content { +width: 100%; +} +#innercontent { +padding: 8px 10px 10px; +} + +.grid { +border-width: 1px; +border-style: solid; +border-color: rgb(225, 225, 225) rgb(210, 210, 210) rgb(210, 210, 210) rgb(210, 210, 210); +background: url(../images/schemaHeader.png) top repeat-x; +} + +.gridheader { +height: 18px; +border-bottom: 1px solid rgb(150, 150, 150); +border-right: 1px solid #fff; +overflow: hidden; +} +.gridheaderinner { +padding-left: 1px; +} + +.headertitle { +background: #EEEEEE url(../images/schemaHeader.png) top; +padding: 0 5px 0 6px; +width: 200px; +cursor: pointer; +overflow: hidden; +display: block; +float: left; +color: rgb(90, 90, 90); +} + +.columnresizer { +border-right: 1px solid rgb(255, 255, 255); +border-left: 1px solid rgb(185, 185, 185); +width: 0; +height: 18px; +cursor: ew-resize; +} + +.emptyvoid { +background: #EEEEEE url(../images/schemaHeader.png) top; +height: 16px; +width: 14px; +padding: 1px 4px; +float: left; +border-bottom: 1px solid rgb(150, 150, 150); +border-right: 1px solid rgb(205, 205, 205); +} + +.impotent .headertitle, .impotent .columnresizer { +cursor: default; +} +.nosort .headertitle { +cursor: default; +} + +.browse { +line-height: 17px; +min-width: 100%; +width: 100%; +} +.browse table td { +border-right: 1px solid rgb(200, 200, 200); +vertical-align: top; +} + +.item { +padding: 2px 6px; +width: 200px; +overflow: hidden; +max-height: 16px; +} +.longtext { +width: 300px; +} +.numeric { +width: 150px; +} +.binary { +font-style: italic; +color: #AAAA8F; +} +.structure .headertitle, .structure .item, .dboverview .headertitle, .dboverview .item { +width: 150px; +} + +.leftchecks { +width: 22px; +position: absolute; +overflow: hidden; +border-right: 1px solid rgb(185, 185, 185); +} +.manip { +padding-top: 1px; +vertical-align: top; +height: 19px; +} +.manip:last-child { +border-bottom: 0 !important; +} +.manip dt { +width: 15px; +padding: 0 1px 0 5px; +float: left; +} +.manip dd { +width: 15px; +padding: 2px 0 0 0; +float: left; +} +.manip dd a { +background: url(../images/info.png) no-repeat; +width: 13px; +height: 13px; +display: block; +cursor: default; +} +.manip dd a:hover { +background: url(../images/infoHover.png) no-repeat; +} +.browsetab .leftchecks { +width: 38px; +} + +.withchecks { +margin-left: 22px; +border-left: 1px solid rgb(240, 240, 240); +} +.withinfo { +margin-left: 39px; +} + +.sort { +color: steelblue; +} +.sortasc { +background: url(../images/sortasc.gif) no-repeat right 6px; +margin-right: 1px; +} +.sortdesc { +background: url(../images/sortdesc.gif) no-repeat right 5px; +margin-right: 1px; +} + +.alternator { +border-bottom: 1px solid #f0f0ff; +} +.alternator2 { +background: #f0f0ff; +border-bottom: 1px solid transparent; +} +.highlighted { +background: #F5F5B8 !important; +border-bottom: 1px solid #E5E6AD !important; +} + +.gridscroll { +overflow: auto; +min-height: 21px; +} + +.gridscroll .browse:last-child { +border-bottom: 0 !important; +} + +.browsenav { +width: 100%; +padding: 2px 0 3px; +} +.browsenav td { +color: rgb(125, 125, 125); +} +.browsenav a { +outline: none; +} +.browsenav .options { +padding-left: 7px; +} +.browsenav .options a { +margin: 0 1px; +} +.browsenav .right { +padding-right: 8px; +text-align: right; +} +.browsenav .right a { +padding-left: 10px; +} +.browsenav .paginator { +padding: 0 3px 0 5px; +} +.browsenav .paginator a { +color: rgb(125, 125, 125); +padding-left: 5px; +} +.browsenav .paginator a.selected { +font-weight: bold; +color: rgb(150, 150, 150); +} + +.insert { +margin: 8px 6px; +width: 350px; +} +.insert td { +padding: 1px 6px 0; +} +.insert .inputarea { +padding-bottom: 8px; +} +.insert .text { +width: 325px; +} +.insert textarea { +width: 325px; +} +.insertseperator { +width: 348px; +margin: 12px 5px; +border-bottom: 2px solid #ccc; +} +.insertmessage { +margin: 1px 4px; +padding: 4px 8px; +color: rgb(75, 75, 75); +width: 332px; +} + +.edit { +border-bottom: 1px solid rgb(175, 175, 175); +margin-bottom: 17px; +} +form:last-child .edit { +border-bottom: 0 !important; +} + +.fieldheader { +color: rgb(110, 110, 110); +} +.fieldheader .fieldheadertitle { +width: 345px; +display: block; +float: left; +} +.fieldheader a.fieldclose { +width: 14px; +height: 16px; +padding-right: 4px; +display: block; +float: right; +background: url(../images/close.png) no-repeat 0 1px; +} +.fieldheader a.fieldclose:hover { +background: url(../images/closeHover.png) no-repeat 0 1px; +} +.secondaryheader { +color: rgb(100, 100, 100); +padding-right: 8px !important; +vertical-align: top; +} +.secondaryheader a { +color: rgb(100, 100, 100); +} + +#fieldlist .fieldbox:first-child .fieldclose { +display: none; +} + +.structure .inputbox { +width: 500px; +margin-top: 15px; +} +.structure .secondaryheader { +width: 65px; +} +.structure .grid { +margin-bottom: 15px; +} + +.columnheader { +color: rgb(125, 125, 125); +padding: 3px 0 0 7px; +cursor: pointer; +} +.column .text { +font-size: 12px; +} + +.paneheader { +margin: 7px 0 0; +color: rgb(115, 115, 115); +} +.paneheader a { +color: rgb(115, 115, 115); +} + +.dboverview .column1 { +width: 200px; +} +.dboverview .inputbox { +width: 500px; +} +.dboverview .inputbox .secondaryheader { +width: 80px; +} + +.overview { +margin: 0px 0 5px 0; +border-bottom: 1px solid rgb(220, 220, 220); +padding: 0 0 3px 0; +} +.inputbox .overview td { +padding: 7px 0 3px; +} +.overview .fieldheader { +border-bottom: 1px solid rgb(220, 220, 220); +padding-bottom: 2px; +} +.overview .text, .overview select, .overview option { +width: 135px; +} + +.editcolumn { +margin-left: 4px; +padding: 12px 0; +width: 430px; +} +.editcolumn table { +width: 100%; +} +.editcolumn td { +padding: 1px 6px 0; +} +.editcolumn .inputarea { +padding-bottom: 8px; +} +.editcolumn .text { +width: 325px; +font-size: 12px !important; +} + +.edituser { +margin: 0 0 4px 13px; +padding: 12px 0; +width: 335px; +border-bottom: 1px solid rgb(175, 175, 175); +} +form:last-child .edituser { +border-bottom: 0 !important; +} +.edituser .edit { +border-bottom: 0; +margin-bottom: 0; +} +.edituser .secondaryheader { +width: 110px; +} + +.users { +padding: 5px 7px 7px; +width: 550px; +} +.users .inputbox { +width: 335px; +} +.users .secondaryheader { +width: 110px; +} +.privpane { +background: rgb(240, 240, 240); +padding: 1px 0px 8px 12px; +margin-top: 5px; +} +#dbaccesspane { +padding-top: 5px !important; +} +.privpane td { +padding: 1px 0 !important; +} + +.export { +padding: 7px 7px 5px 14px; +width: 375px; +} +.export h4 { +padding-bottom: 3px; +} +.export .secondaryheader { +width: 110px; +} +.export .message { +color: rgb(100, 100, 100); +line-height: 14px; +} +.export table { +width: 100%; +} +.export td { +padding: 5px 0; +} +.export select { +width: 100%; +} +.export .text { +font-size: 12px; +width: 100px; +} +.exportseperator { +margin: 7px 0; +border-bottom: 1px solid rgb(210, 210, 210); +} +#EXPORTWRAPPER { +padding: 7px; +} +#EXPORTWRAPPER strong { +color: #646464; +} +#EXPORTRESULTS { +width: 100%; +max-width: 100%; +height: 250px; +font-size: 12px; +margin-top: 3px; +} + +.import { +padding: 7px 7px 5px 14px; +width: 350px; +} +.import h4 { +padding-bottom: 3px; +} +.import .secondaryheader { +width: 80px; +} +.import table { +width: 100%; +} +.import td { +padding: 5px 0; +} +.import .text { +font-size: 12px; +width: 100px; +} + +.inputbox { +padding: 0 7px 5px; +} +.inputbox h4 { +margin-bottom: 5px; +padding-bottom: 2px; +} +.inputbox table { +width: 100%; +} +.inputbox td { +padding: 5px 0; +} +.inputbox .text, .inputbox textarea, .inputbox select[multiple] { +font-size: 12px; +} + +.fulltextwin { +position: absolute; +text-align: left; +color: rgb(240, 240, 240); +width: 475px; +} +.fulltextheader { +height: 21px; +} +.fulltextheader td { +padding: 2px 0; +} +.headertl { +width: 19px; +background: url(../images/window-header-left.png) no-repeat; +} +.headertr { +width: 19px; +background: url(../images/window-header-right.png) no-repeat; +} +.headercenter { +background: url(../images/window-header-center.png) repeat-x; +} + +.fulltextheader p { +margin: 0 !important; +padding-left: 2px; +} +.fulltextheader img { +margin-top: 1px; +} +.mainl { +width: 13px; +background: url(../images/window-shadow-left.png) repeat-y; +} +.maincenter { +background: url(../images/window-center.png); +padding: 5px 5px 0 8px; +} +.fulltextcontent { +overflow: auto; +min-height: 100px; +padding-right: 5px; +} +.mainr { +width: 13px; +background: url(../images/window-shadow-right.png) repeat-y; +} +.fulltexttitle { +color: rgb(175, 175, 175); +font-weight: bold; +} +.fulltextbody { +margin-bottom: 10px; +line-height: 15px; +} +.fulltextfooter { +width: 100%; +} +.fulltextfooter td { +height: 19px; +} +.footerbl { +width: 15px; +background: url(../images/window-shadow-bottom-left.png) no-repeat -1px; +} +.footerbr { +width: 15px; +background: url(../images/window-shadow-bottom-right.png) no-repeat; +} +.footermiddle { +width: auto; +background: url(../images/window-shadow-bottom.png) repeat-x; +} + +.dialog { +width: 475px; +} +.dialog .fulltextcontent { +min-height: 25px; +} +.dialog .maincenter { +padding: 5px 2px 0px 8px !important +} +.buttons { +padding: 7px 0 5px; +} +.windowbutton { +background: url(../images/window-button.png); +padding: 3px 5px 4px; +width: 60px; +height: 22px; +border: 0; +color: white; +outline-color: rgb(130, 130, 130); +outline-width: thin; +} +.resizeHandle { +float: right; +margin-bottom: -1px; +} + +#QUERY { +width: 550px; +font-size: 12px; +display: block; +margin: 2px 0 0; +} + +.querybox { +font-family: "courier new"; +background: rgb(90, 90, 90); +padding: 4px 6px 2px; +margin: 10px 0 1px 0; +max-height: 75px; +overflow: auto; +font-weight: normal; +} + +.clearer { +height: 0; +line-height: 0; +clear: both; +} + +#loginform { +margin: 0 auto; +width: 330px; +margin-top: 115px; +} +#loginform .loginspacer { +padding: 13px 18px 13px 14px; +} +#loginform table { +width: 100%; +} +.loginheader { +border-bottom: 1px solid #E1E1E1; +padding-bottom: 8px !important; +float: left; +width: 100%; +margin-bottom: 10px; +} +.loginheader h3 { +font-size: 13px; +float: left; +} +.loginheader a { +float: right; +text-align: right; +} +#loginform td { +padding: 5px 5px; +line-height: 14px; +} +#loginform .field { +width: 85px; +text-align: right; +color: #4A7496; +} +#loginform select { +width: 165px; +} +#loginform .text { +width: 160px; +color: rgb(70, 70, 70); +font-size: 13px; +} +#loginform .errormess { +color: #AA3939; +padding: 0 0 5px; +text-align: center; +} + +.errormessage { +background: rgb(255, 245, 245); +border: 1px solid rgb(230, 210, 210); +padding: 7px 9px; +line-height: 15px; +color: rgb(80, 80, 80); +} +.errormessage strong { +color: #EB4A4A; +display: block; +margin-bottom: 3px; +} +.errormessage p { +margin-bottom: 0; +} +.statusmessage { +padding: 4px 0; +color: rgb(125, 125, 125); +} + +.hometable { +margin: 7px 0 0 10px; +width: 475px; +} +.hometable p { +line-height: 15px; +} +.hometable table td { +padding-top: 7px; +} +.hometable .text { +width: 130px; +} +.hometable select { +width: 135px; +} +.hometable .inputfield { +color: rgb(140, 140, 140); +width: 95px; +padding-right: 7px; +text-align: right; +} + +.keyboardtable { +width: 445px; +margin-top: 7px; +border-right: 1px solid rgb(200, 200, 200); +border-bottom: 1px solid rgb(200, 200, 200); +} +.keyboardtable td, .keyboardtable th { +padding: 1px 10px 1px 5px !important; +border-left: 1px solid rgb(200, 200, 200); +border-top: 1px solid rgb(200, 200, 200); +} +.keyboardtable th { +color: rgb(125, 125, 125); +font-weight: normal; +text-align: left; +} + +dl.information { +width: 200px; +} +dl.information dt { +float: left; +width: 100px; +clear: left; +color: rgb(125, 125, 125); +} +dl.information dd { +float: left; +width: 100px; +} + +.morelink:hover { +text-decoration: underline; +} + +.errorpage { +padding: 6px 10px 3px; +width: 450px; +} +.errorpage h4 { +font-weight: bold; +} + +.goto { +cursor: pointer; +margin-top: 2px; +opacity: 0.7; +float: right; +} +.goto:hover { +opacity: 1; } \ No newline at end of file diff --git a/htdocs/sqlbuddy/css/navigation.css b/htdocs/sqlbuddy/css/navigation.css index 9b5d2e69d..fdc07ed07 100755 --- a/htdocs/sqlbuddy/css/navigation.css +++ b/htdocs/sqlbuddy/css/navigation.css @@ -1,94 +1,94 @@ -.dblistheader { -padding: 0px 0px 0px 7px; -outline: none; -text-transform: uppercase; -font-size: 10px; -color: rgb(175, 175, 175); -} - -.dblist { -width: 100%; -line-height: 17px; -padding-bottom: 6px; -} -.dblist ul { -padding: 0px; -} -.dblist ul li { -list-style-type: none; -} -.dblist ul li a { -display: block; -outline: none; -border-width: 1px 0 1px 1px; -border-style: solid; -border-color: transparent; -} -.dblist ul li a .menutext { -padding: 1px 6px 0px 0px; -margin-left: 16px; -border: 0; -} -.dblist ul li a .menutoggler { -width: 12px; -height: 14px; -margin: 3px 4px 0px 2px; -float: left; -background: transparent url(../images/closedArrow.png) no-repeat 4px 3px; -} -.dblist ul li a .menuicon { -height: 14px; -margin: 0px 5px 0px 6px; -float: left; -font-size: 10px; -padding-top: 1px; -} -.dblist ul li.expanded a .menutoggler{ -background: transparent url(../images/openArrow.png) no-repeat 3px 3px; -} -.dblist ul li.expanded .sublist { -display: block; -} - -.sublist { -border: 0px !important; -overflow: hidden; -} -.sublist li a { -padding: 1px 6px 0px 22px !important; -margin-left: 7px; -overflow-x: hidden; -} -.sublist li.loading a { -background: url(../images/loading.gif) no-repeat 0 0 !important; -} -.subcount { -padding-left: 5px; -font-size: 11px; -} - -#toptabs { -padding-top: 7px; -float: left; -} -#toptabs ul { -padding: 0; -} -#toptabs ul li { -list-style-type: none; -float: left; -} -#toptabs ul li a { -margin: 0 5px 0 15px; -outline: none; -} -#toptabs ul li a .rowcount { -font-weight: normal; -padding-left: 3px; -} -#toptabs ul li.selected a { -cursor: default; -} -#toptabs ul li.deactivated a { -cursor: default; +.dblistheader { +padding: 0px 0px 0px 7px; +outline: none; +text-transform: uppercase; +font-size: 10px; +color: rgb(175, 175, 175); +} + +.dblist { +width: 100%; +line-height: 17px; +padding-bottom: 6px; +} +.dblist ul { +padding: 0px; +} +.dblist ul li { +list-style-type: none; +} +.dblist ul li a { +display: block; +outline: none; +border-width: 1px 0 1px 1px; +border-style: solid; +border-color: transparent; +} +.dblist ul li a .menutext { +padding: 1px 6px 0px 0px; +margin-left: 16px; +border: 0; +} +.dblist ul li a .menutoggler { +width: 12px; +height: 14px; +margin: 3px 4px 0px 2px; +float: left; +background: transparent url(../images/closedArrow.png) no-repeat 4px 3px; +} +.dblist ul li a .menuicon { +height: 14px; +margin: 0px 5px 0px 6px; +float: left; +font-size: 10px; +padding-top: 1px; +} +.dblist ul li.expanded a .menutoggler{ +background: transparent url(../images/openArrow.png) no-repeat 3px 3px; +} +.dblist ul li.expanded .sublist { +display: block; +} + +.sublist { +border: 0px !important; +overflow: hidden; +} +.sublist li a { +padding: 1px 6px 0px 22px !important; +margin-left: 7px; +overflow-x: hidden; +} +.sublist li.loading a { +background: url(../images/loading.gif) no-repeat 0 0 !important; +} +.subcount { +padding-left: 5px; +font-size: 11px; +} + +#toptabs { +padding-top: 7px; +float: left; +} +#toptabs ul { +padding: 0; +} +#toptabs ul li { +list-style-type: none; +float: left; +} +#toptabs ul li a { +margin: 0 5px 0 15px; +outline: none; +} +#toptabs ul li a .rowcount { +font-weight: normal; +padding-left: 3px; +} +#toptabs ul li.selected a { +cursor: default; +} +#toptabs ul li.deactivated a { +cursor: default; } \ No newline at end of file diff --git a/htdocs/sqlbuddy/css/print.css b/htdocs/sqlbuddy/css/print.css index 38d77463f..16333ff33 100755 --- a/htdocs/sqlbuddy/css/print.css +++ b/htdocs/sqlbuddy/css/print.css @@ -1,27 +1,27 @@ -#header { -display: none; -} - -.inputbutton, .inputbutton:active { -background: default !important; -border: default !important; -line-height: inherit !important; -width: auto !important; -height: auto !important; -} - -#innercontent a { -color: #3A6D96 !important; -} - -.leftchecks, .emptyvoid { -display: none !important; -} -.gridscroll, .gridheader { -max-height: none !important; -max-width: none !important; -overflow: none !important; -} -.withinfo, .withchecks { -margin-left: 0 !important; +#header { +display: none; +} + +.inputbutton, .inputbutton:active { +background: default !important; +border: default !important; +line-height: inherit !important; +width: auto !important; +height: auto !important; +} + +#innercontent a { +color: #3A6D96 !important; +} + +.leftchecks, .emptyvoid { +display: none !important; +} +.gridscroll, .gridheader { +max-height: none !important; +max-width: none !important; +overflow: none !important; +} +.withinfo, .withchecks { +margin-left: 0 !important; } \ No newline at end of file diff --git a/htdocs/sqlbuddy/dboverview.php b/htdocs/sqlbuddy/dboverview.php index 1082c5e41..d1c429189 100755 --- a/htdocs/sqlbuddy/dboverview.php +++ b/htdocs/sqlbuddy/dboverview.php @@ -1,578 +1,577 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if (isset($db)) { - -$conn->selectDB($db); - -//run delete queries - -if (isset($_POST['runQuery'])) { - - $runQuery = $_POST['runQuery']; - - $queryList = splitQueryText($runQuery); - - foreach ($queryList as $query) { - $query = trim($query); - - if ($query != "") { - $conn->query($query) or ($dbError = $conn->error()); - - // make a list of the tables that were dropped/emptied - if (substr($query, 0, 10) == "DROP TABLE") - $droppedList[] = substr($query, 12, -1); - - if (substr($query, 0, 10) == "TRUNCATE `") - $emptiedList[] = substr($query, 10, -1); - - if (substr($query, 0, 13) == "DELETE FROM '") - $emptiedList[] = substr($query, 13, -1); - - } - } -} - -// if tables were dropped, remove them from the side menu -if (isset($droppedList) && isset($db)) { - ?> - - - - - - - - '; - echo __("Error performing operation"); - echo '

' . $dbError . '

'; -} - -?> - - - - -
- -listTables(); - -if ($conn->isResultSet($tableSql)) { - - echo '
'; - - echo ''; - echo ''; - echo ''; - echo ''; - echo '
'; - - echo __("Select") . ':  ' . __("All") . '  ' . __("None") . ''; - echo '     ' . __("With selected") . ':  ' . __("Empty") . '  ' . __("Drop") . ''; - - if ($conn->getAdapter() == "mysql") { - echo '  ' . __("Optimize") . ''; - } - - echo '
'; - - echo '
'; - - echo '
 
'; - - echo '
'; - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - if (isset($charsetList) && isset($collationList)) { - echo ''; - echo ''; - echo ''; - echo ''; - } else if ($conn->getAdapter() == "mysql") { - echo ''; - echo ''; - } - - echo ''; - echo ''; - echo '
' . __("Table") . '
' . __("Rows") . '
' . __("Charset") . '
' . __("Overhead") . '
' . __("Overhead") . '
 
'; - echo '
'; - echo '
'; - - echo '
'; - - $m = 0; - - while ($tableRow = $conn->fetchArray($tableSql)) { - echo '
'; - } - - echo '
'; - - $tableSql = $conn->listTables(); - - echo '
'; - - $m = 0; - - while ($tableRow = $conn->fetchArray($tableSql)) { - - $rowCount = $conn->tableRowCount($tableRow[0]); - - if ($conn->getAdapter() == "mysql") { - $infoSql = $conn->query("SHOW TABLE STATUS LIKE '" . $tableRow[0] . "'"); - $infoRow = $conn->fetchAssoc($infoSql); - - $overhead = $infoRow["Data_free"]; - - $formattedOverhead = ""; - - if ($overhead > 0) - $formattedOverhead = memoryFormat($overhead); - } - - echo '
'; - echo ''; - echo ''; - echo ''; - echo ''; - - if (isset($collationList) && array_key_exists("Collation", $infoRow) && array_key_exists($infoRow['Collation'], $collationList)) { - echo ''; - echo ''; - } else if ($conn->getAdapter() == "mysql") { - echo ''; - echo ''; - } - - echo ''; - echo '
' . $tableRow[0] . '
' . number_format($rowCount) . '
' . $collationList[$infoRow['Collation']] . '
' . $formattedOverhead . '
 
' . $formattedOverhead . '
'; - echo '
'; - - $m++; - } - - echo '
'; - echo '
'; - - echo '
'; - -} - -if ($conn->getAdapter() != "sqlite") { - -?> - -
-

- - -
- -query("SHOW VARIABLES LIKE 'character_set_database'"); - -if ($conn->isResultSet($currentCharSql)) { - $currentChar = $conn->result($currentCharSql, 0, "Value"); -} - -?> - -
-

- -
-
- - -"; - echo ""; - echo ""; - echo ''; - echo ""; - -?> - -
"; - echo __("Charset") . ":"; - echo ""; - echo ""; - echo "'; - echo ''; - echo '
-
-
- - - - - -
-

- -
- - - - - - "; - echo ""; - echo ""; - echo ""; - } - - ?> - - - -
- : - - -
"; - echo __("Charset") . ":"; - echo ""; - echo ""; - echo "
- : -
-
- -
- - - - - getAdapter() == "mysql") { - - ?> - - - - - - - - - - - - - - - - - - - - - "; - echo __("Charset") . ":"; - echo ""; - echo ""; - } else { - echo ""; - echo ""; - } - - ?> - - - - - - getAdapter() == "sqlite") { - - ?> - - - - - - - - - - - - - - - - - - - - - - - -
- <> - -
- : - - - - : - - -
- : - - - - : - - -
- : - - - "; - echo ""; - echo "
- : - - - - - -
- : - - - - : - - -
- : - - - - : - - -
- : - - -
- : - - - - getVersion(), "3.0.0", ">=")) { - ?> - - -
-
- -
- - - - - - -
- " /> - -
-
-
- -
- -
- - - - - -
-

-

-
- - + +*/ + +include "functions.php"; + +loginCheck(); + +if (isset($db)) { + +$conn->selectDB($db); + +//run delete queries + +if (isset($_POST['runQuery'])) { + + $runQuery = $_POST['runQuery']; + + $queryList = splitQueryText($runQuery); + + foreach ($queryList as $query) { + $query = trim($query); + + if ($query != "") { + $conn->query($query) or ($dbError = $conn->error()); + + // make a list of the tables that were dropped/emptied + if (substr($query, 0, 10) == "DROP TABLE") + $droppedList[] = substr($query, 12, -1); + + if (substr($query, 0, 10) == "TRUNCATE `") + $emptiedList[] = substr($query, 10, -1); + + if (substr($query, 0, 13) == "DELETE FROM '") + $emptiedList[] = substr($query, 13, -1); + + } + } +} + +// if tables were dropped, remove them from the side menu +if (isset($droppedList) && isset($db)) { + ?> + + + + + + + + '; + echo __("Error performing operation"); + echo '

' . $dbError . '

'; +} + +?> + + + + +
+ +listTables(); + +if ($conn->isResultSet($tableSql)) { + + echo '
'; + + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'; + + echo __("Select") . ':  ' . __("All") . '  ' . __("None") . ''; + echo '     ' . __("With selected") . ':  ' . __("Empty") . '  ' . __("Drop") . ''; + + if ($conn->getAdapter() == "mysql") { + echo '  ' . __("Optimize") . ''; + } + + echo '
'; + + echo '
'; + + echo '
 
'; + + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + if (isset($charsetList) && isset($collationList)) { + echo ''; + echo ''; + echo ''; + echo ''; + } else if ($conn->getAdapter() == "mysql") { + echo ''; + echo ''; + } + + echo ''; + echo ''; + echo '
' . __("Table") . '
' . __("Rows") . '
' . __("Charset") . '
' . __("Overhead") . '
' . __("Overhead") . '
 
'; + echo '
'; + echo '
'; + + echo '
'; + + $m = 0; + + while ($tableRow = $conn->fetchArray($tableSql)) { + echo '
'; + } + + echo '
'; + + $tableSql = $conn->listTables(); + + echo '
'; + + $m = 0; + + while ($tableRow = $conn->fetchArray($tableSql)) { + + $rowCount = $conn->tableRowCount($tableRow[0]); + + if ($conn->getAdapter() == "mysql") { + $infoSql = $conn->query("SHOW TABLE STATUS LIKE '" . $tableRow[0] . "'"); + $infoRow = $conn->fetchAssoc($infoSql); + + $overhead = $infoRow["Data_free"]; + + $formattedOverhead = ""; + + if ($overhead > 0) + $formattedOverhead = memoryFormat($overhead); + } + + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + + if (isset($collationList) && array_key_exists("Collation", $infoRow)) { + echo ''; + echo ''; + } else if ($conn->getAdapter() == "mysql") { + echo ''; + } + + echo ''; + echo '
' . $tableRow[0] . '
' . number_format($rowCount) . '
' . $collationList[$infoRow['Collation']] . '
' . $formattedOverhead . '
' . $formattedOverhead . '
'; + echo '
'; + + $m++; + } + + echo '
'; + echo '
'; + + echo '
'; + +} + +if ($conn->getAdapter() != "sqlite") { + +?> + +
+

+ + +
+ +query("SHOW VARIABLES LIKE 'character_set_database'"); + +if ($conn->isResultSet($currentCharSql)) { + $currentChar = $conn->result($currentCharSql, 0, "Value"); +} + +?> + +
+

+ +
+
+ + +"; + echo ""; + echo ""; + echo ''; + echo ""; + +?> + +
"; + echo __("Charset") . ":"; + echo ""; + echo ""; + echo "'; + echo ''; + echo '
+
+
+ + + + + +
+

+ +
+ + + + + + "; + echo ""; + echo ""; + echo ""; + } + + ?> + + + +
+ : + + +
"; + echo __("Charset") . ":"; + echo ""; + echo ""; + echo "
+ : +
+
+ +
+ + + + + getAdapter() == "mysql") { + + ?> + + + + + + + + + + + + + + + + + + + + + "; + echo __("Charset") . ":"; + echo ""; + echo ""; + } else { + echo ""; + echo ""; + } + + ?> + + + + + + getAdapter() == "sqlite") { + + ?> + + + + + + + + + + + + + + + + + + + + + + + +
+ <> + +
+ : + + + + : + + +
+ : + + + + : + + +
+ : + + + "; + echo ""; + echo "
+ : + + + + + +
+ : + + + + : + + +
+ : + + + + : + + +
+ : + + +
+ : + + + + getVersion(), "3.0.0", ">=")) { + ?> + + +
+
+ +
+ + + + + + +
+ " /> + +
+
+
+ +
+ +
+ + + + + +
+

+

+
+ + \ No newline at end of file diff --git a/htdocs/sqlbuddy/edit.php b/htdocs/sqlbuddy/edit.php index 34542f39e..92d507c11 100755 --- a/htdocs/sqlbuddy/edit.php +++ b/htdocs/sqlbuddy/edit.php @@ -1,210 +1,210 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -requireDatabaseAndTableBeDefined(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($table)) - $structureSql = $conn->describeTable($table); - -if (isset($_POST['editParts'])) { - $editParts = $_POST['editParts']; - $editParts = explode("; ", $editParts); - - $totalParts = count($editParts); - $counter = 0; - - $firstField = true; - - ?> - - - -
- - - isResultSet($structureSql) && $conn->getAdapter() == "mysql") { - - $dataSql = $conn->query("SELECT * FROM `" . $table . "` " . $part); - $dataRow = $conn->fetchAssoc($dataSql); - - while ($structureRow = $conn->fetchAssoc($structureSql)) { - - preg_match("/^([a-z]+)(.([0-9]+).)?(.*)?$/", $structureRow['Type'], $matches); - - $curtype = $matches[1]; - $cursizeQuotes = $matches[2]; - $cursize = $matches[3]; - $curextra = $matches[4]; - - echo ''; - echo ''; - echo ''; - echo ''; - echo ' - - - describeTable($table); - - } else if (sizeof($structureSql) > 0 && $conn->getAdapter() == "sqlite") { - - $dataSql = $conn->query("SELECT * FROM '" . $table . "' " . $part); - $dataRow = $conn->fetchAssoc($dataSql); - - foreach ($structureSql as $column) { - - echo ''; - echo ''; - echo ''; - echo ''; - echo ' - - - describeTable($table); - - } - - ?> - - - - - - -
'; - if ($structureRow['Key'] == 'PRI') echo ''; - echo $structureRow['Field']; - if ($structureRow['Key'] == 'PRI') echo ''; - echo " " . $curtype . $cursizeQuotes . ' ' . $structureRow['Extra'] . '
'; - - $showLargeEditor[] = "text"; - $showLargeEditor[] = "mediumtext"; - $showLargeEditor[] = "longtext"; - - if (in_array($curtype, $showLargeEditor)) { - echo ''; - } - elseif ($curtype == "enum") { - $trimmed = substr($structureRow['Type'], 6, -2); - $listOptions = explode("','", $trimmed); - echo ''; - } - elseif ($curtype == "set") { - $trimmed = substr($structureRow['Type'], 5, -2); - $listOptions = explode("','", $trimmed); - foreach ($listOptions as $option) { - $id = $option . rand(1, 1000); - echo '
'; - } - } else { - echo ''; - } - - $firstField = false; - - ?> - -
'; - if (strpos($column[1], "primary key") > 0) echo ''; - echo $column[0]; - if (strpos($column[1], "primary key") > 0) echo ''; - echo " " . $column[1] . '
'; - - if (strpos($column[1], "text") !== false) { - echo ''; - } else { - echo ''; - } - - $firstField = false; - - ?> - -
-
- -
- " />   -
-
- - - + +*/ + +include "functions.php"; + +loginCheck(); + +requireDatabaseAndTableBeDefined(); + +if (isset($db)) + $conn->selectDB($db); + +if (isset($table)) + $structureSql = $conn->describeTable($table); + +if (isset($_POST['editParts'])) { + $editParts = $_POST['editParts']; + $editParts = explode("; ", $editParts); + + $totalParts = count($editParts); + $counter = 0; + + $firstField = true; + + ?> + + + +
+ + + isResultSet($structureSql) && $conn->getAdapter() == "mysql") { + + $dataSql = $conn->query("SELECT * FROM `" . $table . "` " . $part); + $dataRow = $conn->fetchAssoc($dataSql); + + while ($structureRow = $conn->fetchAssoc($structureSql)) { + + preg_match("/^([a-z]+)(.([0-9]+).)?(.*)?$/", $structureRow['Type'], $matches); + + $curtype = $matches[1]; + $cursizeQuotes = $matches[2]; + $cursize = $matches[3]; + $curextra = $matches[4]; + + echo ''; + echo ''; + echo ''; + echo ''; + echo ' + + + describeTable($table); + + } else if (sizeof($structureSql) > 0 && $conn->getAdapter() == "sqlite") { + + $dataSql = $conn->query("SELECT * FROM '" . $table . "' " . $part); + $dataRow = $conn->fetchAssoc($dataSql); + + foreach ($structureSql as $column) { + + echo ''; + echo ''; + echo ''; + echo ''; + echo ' + + + describeTable($table); + + } + + ?> + + + + + + +
'; + if ($structureRow['Key'] == 'PRI') echo ''; + echo $structureRow['Field']; + if ($structureRow['Key'] == 'PRI') echo ''; + echo " " . $curtype . $cursizeQuotes . ' ' . $structureRow['Extra'] . '
'; + + $showLargeEditor[] = "text"; + $showLargeEditor[] = "mediumtext"; + $showLargeEditor[] = "longtext"; + + if (in_array($curtype, $showLargeEditor)) { + echo ''; + } + elseif ($curtype == "enum") { + $trimmed = substr($structureRow['Type'], 6, -2); + $listOptions = explode("','", $trimmed); + echo ''; + } + elseif ($curtype == "set") { + $trimmed = substr($structureRow['Type'], 5, -2); + $listOptions = explode("','", $trimmed); + foreach ($listOptions as $option) { + $id = $option . rand(1, 1000); + echo '
'; + } + } else { + echo ''; + } + + $firstField = false; + + ?> + +
'; + if (strpos($column[1], "primary key") > 0) echo ''; + echo $column[0]; + if (strpos($column[1], "primary key") > 0) echo ''; + echo " " . $column[1] . '
'; + + if (strpos($column[1], "text") !== false) { + echo ''; + } else { + echo ''; + } + + $firstField = false; + + ?> + +
+
+ +
+ " />   +
+
+ + + \ No newline at end of file diff --git a/htdocs/sqlbuddy/editcolumn.php b/htdocs/sqlbuddy/editcolumn.php index 88e079d75..cae875757 100755 --- a/htdocs/sqlbuddy/editcolumn.php +++ b/htdocs/sqlbuddy/editcolumn.php @@ -1,189 +1,189 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -requireDatabaseAndTableBeDefined(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($db)) - $structureSql = $conn->query("SHOW FULL FIELDS FROM `$table`"); - -if (isset($_POST['editParts']) && $conn->isResultSet($structureSql)) { - - $editParts = $_POST['editParts']; - - $editParts = explode("; ", $editParts); - - $totalParts = count($editParts); - $counter = 0; - - $firstField = true; - - ?> - - fetchAssoc($structureSql)) { - if (in_array($structureRow['Field'], $editParts)) { - echo '
'; - echo '
'; - echo ''; - echo ''; - - preg_match("/^([a-z]+)(.([0-9]+).)?(.*)?$/", $structureRow['Type'], $matches); - - $curtype = $matches[1]; - $cursizeQuotes = $matches[2]; - $cursize = $matches[3]; - $curextra = $matches[4]; - - ?> - - - - - - - - '; - - ?> - - - - - - - - - - - "; - echo ""; - echo ""; - echo ""; - } - - ?> - - - - - - - - - - -
- - - value="" style="width: 125px" /> - - - - -
- - - " style="width: 125px" /> - -
- - - - - - - -
"; - echo __("Charset:"); - echo ""; - echo ""; - echo "
- - - - - -
- " />   -
-
-
- - + +*/ + +include "functions.php"; + +loginCheck(); + +requireDatabaseAndTableBeDefined(); + +if (isset($db)) + $conn->selectDB($db); + +if (isset($db)) + $structureSql = $conn->query("SHOW FULL FIELDS FROM `$table`"); + +if (isset($_POST['editParts']) && $conn->isResultSet($structureSql)) { + + $editParts = $_POST['editParts']; + + $editParts = explode("; ", $editParts); + + $totalParts = count($editParts); + $counter = 0; + + $firstField = true; + + ?> + + fetchAssoc($structureSql)) { + if (in_array($structureRow['Field'], $editParts)) { + echo '
'; + echo '
'; + echo ''; + echo ''; + + preg_match("/^([a-z]+)(.([0-9]+).)?(.*)?$/", $structureRow['Type'], $matches); + + $curtype = $matches[1]; + $cursizeQuotes = $matches[2]; + $cursize = $matches[3]; + $curextra = $matches[4]; + + ?> + + + + + + + + '; + + ?> + + + + + + + + + + + "; + echo ""; + echo ""; + echo ""; + } + + ?> + + + + + + + + + + +
+ + + value="" style="width: 125px" /> + + + + +
+ + + " style="width: 125px" /> + +
+ + + + + + + +
"; + echo __("Charset:"); + echo ""; + echo ""; + echo "
+ + + + + +
+ " />   +
+
+
+ + \ No newline at end of file diff --git a/htdocs/sqlbuddy/edituser.php b/htdocs/sqlbuddy/edituser.php index 248b0ee96..50615b3e6 100755 --- a/htdocs/sqlbuddy/edituser.php +++ b/htdocs/sqlbuddy/edituser.php @@ -1,254 +1,254 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -$conn->selectDB("mysql"); - -if (isset($_POST['editParts'])) { - $editParts = $_POST['editParts']; - - $editParts = explode("; ", $editParts); - - $totalParts = count($editParts); - $counter = 0; - - $firstField = true; - - foreach ($editParts as $part) { - $part = trim($part); - - if ($part != "" && $part != ";") { - - list($user, $host) = explode("@", $part); - - $userSQL = $conn->query("SELECT * FROM `user` WHERE `User`='" . $user . "' AND `Host`='" . $host . "'"); - $dbuserSQL = $conn->query("SELECT * FROM `db` WHERE `User`='" . $user . "' AND `Host`='" . $host . "'"); - - if ($conn->isResultSet($userSQL)) { - - $allPrivs = true; - - $dbShowList = array(); - - if ($conn->isResultSet($dbuserSQL)) { - - $accessLevel = "LIMITED"; - - while ($dbuserRow = $conn->fetchAssoc($dbuserSQL)) { - $selectedPrivs = array(); - - $dbShowList[] = $dbuserRow['Db']; - - foreach ($dbuserRow as $key=>$value) { - if (substr($key, -5) == "_priv" && $key != "Grant_priv" && $value == "N") { - $allPrivs = false; - } - - if ($value == "N") - $selectedPrivs[$key] = $value; - } - - if (isset($thePrivList)) { - $thePrivList = array_merge($thePrivList, $selectedPrivs); - } else { - $thePrivList = $dbuserRow; - } - } - } else { - $accessLevel = "GLOBAL"; - - $userRow = $conn->fetchAssoc($userSQL); - - foreach ($userRow as $key=>$value) { - if (substr($key, -5) == "_priv" && $key != "Grant_priv" && $value == "N") { - $allPrivs = false; - } - } - - $thePrivList = $userRow; - } - - echo '
'; - echo '
'; - echo ''; - echo ''; - - ?> - - - - - - - - - - listDatabases(); - - if ($conn->isResultSet($dbList)) { - - ?> - - - - - - - - - -
:
:
: -
- - - - -
: -
- - -
> -
- -
- - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
- - - -
- -
-
-
- -
- - - - - - - - - - - - - -
- - - -
- - - -
- - -
-
-
- -
- - - - - - -
: - -
- -
- " />   -
-
-
- - + +*/ + +include "functions.php"; + +loginCheck(); + +$conn->selectDB("mysql"); + +if (isset($_POST['editParts'])) { + $editParts = $_POST['editParts']; + + $editParts = explode("; ", $editParts); + + $totalParts = count($editParts); + $counter = 0; + + $firstField = true; + + foreach ($editParts as $part) { + $part = trim($part); + + if ($part != "" && $part != ";") { + + list($user, $host) = explode("@", $part); + + $userSQL = $conn->query("SELECT * FROM `user` WHERE `User`='" . $user . "' AND `Host`='" . $host . "'"); + $dbuserSQL = $conn->query("SELECT * FROM `db` WHERE `User`='" . $user . "' AND `Host`='" . $host . "'"); + + if ($conn->isResultSet($userSQL)) { + + $allPrivs = true; + + $dbShowList = array(); + + if ($conn->isResultSet($dbuserSQL)) { + + $accessLevel = "LIMITED"; + + while ($dbuserRow = $conn->fetchAssoc($dbuserSQL)) { + $selectedPrivs = array(); + + $dbShowList[] = $dbuserRow['Db']; + + foreach ($dbuserRow as $key=>$value) { + if (substr($key, -5) == "_priv" && $key != "Grant_priv" && $value == "N") { + $allPrivs = false; + } + + if ($value == "N") + $selectedPrivs[$key] = $value; + } + + if (isset($thePrivList)) { + $thePrivList = array_merge($thePrivList, $selectedPrivs); + } else { + $thePrivList = $dbuserRow; + } + } + } else { + $accessLevel = "GLOBAL"; + + $userRow = $conn->fetchAssoc($userSQL); + + foreach ($userRow as $key=>$value) { + if (substr($key, -5) == "_priv" && $key != "Grant_priv" && $value == "N") { + $allPrivs = false; + } + } + + $thePrivList = $userRow; + } + + echo '
'; + echo '
'; + echo ''; + echo ''; + + ?> + + + + + + + + + + listDatabases(); + + if ($conn->isResultSet($dbList)) { + + ?> + + + + + + + + + +
:
:
: +
+ + + + +
: +
+ + +
> +
+ +
+ + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ +
+
+
+ +
+ + + + + + + + + + + + + +
+ + + +
+ + + +
+ + +
+
+
+ +
+ + + + + + +
: + +
+ +
+ " />   +
+
+
+ + \ No newline at end of file diff --git a/htdocs/sqlbuddy/export.php b/htdocs/sqlbuddy/export.php index 506252186..b8797d286 100755 --- a/htdocs/sqlbuddy/export.php +++ b/htdocs/sqlbuddy/export.php @@ -1,677 +1,677 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if ($_POST) { - - $outputBuffer = ""; - - if (isset($db)) { - $dbs[] = $db; - - if (isset($table)) - $tables[] = $table; - else if (isset($_POST['EXPORTTABLE'])) - $tables = $_POST['EXPORTTABLE']; - } else { - if (isset($_POST['EXPORTDB'])) - $dbs = $_POST['EXPORTDB']; - $exportDb = true; - } - - if (isset($_POST['FORMAT'])) - $format = strtoupper($_POST['FORMAT']); - - if (isset($_POST['STRUCTURE'])) - $exportStructure = $_POST['STRUCTURE']; - - if (isset($_POST['DATA'])) - $exportData = $_POST['DATA']; - - if (isset($_POST['DELIMITER'])) - $delimiter = $_POST['DELIMITER']; - - if (isset($_POST['FIELDNAMES'])) - $printFieldnames = $_POST['FIELDNAMES']; - - if (isset($_POST['INSERTTYPE'])) - $insertType = $_POST['INSERTTYPE']; - - if (isset($_POST['OUTPUT'])) - $output = $_POST['OUTPUT']; - - if (isset($_POST['OUTPUTFILETEXT'])) { - $outputFile = "exports/" . basename($_POST['OUTPUTFILETEXT']); - } - - if (!isset($delimiter) || $delimiter == "TAB") - $delimiter = "\t"; - else if ($delimiter == "SEMICOLON") - $delimiter = ";"; - else if ($delimiter == "SPACE") - $delimiter = " "; - else - $delimiter = ","; - - // for the next three - it has to be one or the other - // this way, if we get fed garbage, just go with a default - if (!isset($format) || $format != "CSV") - $format = "SQL"; - - if (!isset($output) || $output != "FILE" || !isset($outputFile)) - $output = "BROWSER"; - - if (!isset($insertType) || $insertType != "COMPLETE") - $insertType = "COMPACT"; - - if (isset($format) && $format == "SQL" && !isset($exportStructure) && !isset($exportData)) { - $error = __("You must export either structure, data, or both") . "."; - } else if (!isset($dbs)) { - $error = __("Please select the databases that you would like to export") . "."; - } else if (isset($db) && !isset($tables)) { - $error = __("Please select the tables that you would like to export") . "."; - } else { - - if ($format == "SQL") { - - $version = $conn->getVersion(); - - $outputBuffer .= "--\r\n"; - - if ($conn->getAdapter() == "mysql") - $outputBuffer .= "-- MySQL " . $version . "\r\n"; - else if ($conn->getAdapter() == "sqlite") - $outputBuffer .= "-- SQLite " . $version . "\r\n"; - - $outputBuffer .= "-- " . date("r") . "\r\n"; - $outputBuffer .= "--\r\n\r\n"; - } - - foreach ($dbs as $d) { - - $conn->selectDB($d); - - // this checks to see if we are exporting an entire db with all tables - if (isset($exportDb) && $exportDb == true) { - - if ($format == "SQL") { - - $outputBuffer .= "CREATE DATABASE `$d`"; - - if ($conn->hasCharsetSupport()) - { - $currentChar = ""; - $currentCharSql = $conn->query("SHOW VARIABLES LIKE 'character_set_database'"); - - if ($conn->isResultSet($currentCharSql)) { - $currentChar = $conn->result($currentCharSql, 0, "Value"); - - $outputBuffer .= " DEFAULT CHARSET " . $currentChar; - } - } - - $outputBuffer .= ";\r\n\r\n"; - - $outputBuffer .= "USE `$d`;\r\n\r\n"; - - } - - $tableSql = $conn->listTables(); - - $tables = ""; - - if ($conn->isResultSet($tableSql)) { - while ($tableRow = $conn->fetchArray($tableSql)) { - $tables[] = $tableRow[0]; - } - } - } - - foreach ($tables as $t) { - - if ($format == "SQL") { - - if ($conn->getAdapter() == "mysql") - $structureSQL = $conn->query("SHOW FULL FIELDS FROM `$t`"); - else - $structureSQL = $conn->describeTable($t); - - $tableEngine = ""; - $tableCharset = ""; - $autoIncrement = ""; - - if (isset($exportStructure)) { - - if ($conn->isResultSet($structureSQL)) { - - if ($conn->getAdapter() == "mysql") { - - $outputBuffer .= "CREATE TABLE `$t` ("; - - $infoSql = $conn->query("SHOW TABLE STATUS LIKE '$t'"); - - if ($conn->isResultSet($infoSql) == 1) { - - $infoRow = $conn->fetchAssoc($infoSql); - - $tableEngine = (array_key_exists("Type", $infoRow)) ? $infoRow['Type'] : $infoRow['Engine']; - - if (array_key_exists('Collation', $infoRow) && isset($collationList)) { - $tableCharset = $collationList[$infoRow['Collation']]; - } - - if (array_key_exists('Auto_increment', $infoRow)) - { - $autoIncrement = $infoRow['Auto_increment']; - } - } - - } else if ($conn->getAdapter() == "sqlite") { - - $outputBuffer .= "CREATE TABLE '$t' ("; - } - - $first = true; - - if ($conn->getAdapter() == "mysql") { - - while ($structureRow = $conn->fetchassoc($structureSQL)) { - - if (!$first) - $outputBuffer .= ","; - - $outputBuffer .= "\r\n `" . $structureRow['Field'] . "` " . $structureRow['Type']; - - if (isset($collationList) && isset($structureRow['Collation']) && $structureRow['Collation'] != "NULL" && !is_null($structureRow['Collation'])) { - if ($collationList[$structureRow['Collation']] != $tableCharset) { - $outputBuffer .= " CHARSET " . $collationList[$structureRow['Collation']]; - } - } - - if (isset($structureRow['Null']) && $structureRow['Null'] != "YES") - $outputBuffer .= " not null"; - - if (isset($structureRow['Default']) && $structureRow['Default'] == "CURRENT_TIMESTAMP") { - $outputBuffer .= " default CURRENT_TIMESTAMP"; - } else if (isset($structureRow['Default']) && $structureRow['Default'] != "") { - $outputBuffer .= " default '" . $structureRow['Default'] . "'"; - } - - if (isset($structureRow['Extra']) && $structureRow['Extra'] != "") - $outputBuffer .= " " . $structureRow['Extra']; - - $first = false; - } - - } else if ($conn->getAdapter() == "sqlite") { - - foreach ($structureSQL as $structureRow) { - - if (!$first) - $outputBuffer .= ","; - - $outputBuffer .= "\r\n " . $structureRow[0] . " " . $structureRow[1]; - - $first = false; - } - - } - - // dont forget about the keys - if ($conn->getAdapter() == "mysql") { - $keySQL = $conn->query("SHOW INDEX FROM `$t`"); - - if ($conn->isResultSet($keySQL)) { - $currentKey = ""; - while ($keyRow = $conn->fetchAssoc($keySQL)) { - // if this is the start of a key - if ($keyRow['Key_name'] != $currentKey) { - // finish off the last key first, if necessary - if ($currentKey != "") - $outputBuffer .= ")"; - - if ($keyRow['Key_name'] == "PRIMARY") - $outputBuffer .= ",\r\n PRIMARY KEY ("; - elseif ($keyRow['Non_unique'] == "0") - $outputBuffer .= ",\r\n UNIQUE KEY ("; - else - $outputBuffer .= ",\r\n KEY `" . $keyRow['Key_name'] . "` ("; - - $outputBuffer .= "`" . $keyRow['Column_name'] . "`"; - } else { - $outputBuffer .= ",`" . $keyRow['Column_name'] . "`"; - } - - $currentKey = $keyRow['Key_name']; - } - - if (isset($currentKey) && $currentKey != "") - $outputBuffer .= ")"; - } - } - - $outputBuffer .= "\r\n)"; - - if ($conn->getAdapter() == "mysql") { - if ($tableEngine) { - $outputBuffer .= ' ENGINE=' . $tableEngine; - } - - if ($tableCharset) { - $outputBuffer .= ' DEFAULT CHARSET=' . $tableCharset; - } - - if ($autoIncrement) - { - $outputBuffer .= ' AUTO_INCREMENT=' . $autoIncrement; - } - } - - $outputBuffer .= ";\r\n\r\n"; - } - } - - if ($conn->getAdapter() == "mysql") - $structureSQL = $conn->query("SHOW FULL FIELDS FROM `$t`"); - else - $structureSQL = $conn->describeTable($t); - - if (isset($exportData)) { - - $columnList = array(); - - if ($conn->getAdapter() == "mysql") { - - $dataSQL = $conn->query("SELECT * FROM `$t`"); - - // put the column names in an array - if ($conn->isResultSet($structureSQL)) { - while ($structureRow = $conn->fetchAssoc($structureSQL)) { - $columnList[] = $structureRow['Field']; - $type[] = $structureRow['Type']; - } - } - - $columnImplosion = implode("`, `", $columnList); - - if ($conn->isResultSet($dataSQL)) { - - if ($insertType == "COMPACT") - $outputBuffer .= "INSERT INTO `$t` (`$columnImplosion`) VALUES \r\n"; - - $firstLine = true; - - while ($dataRow = $conn->fetchAssoc($dataSQL)) { - - if ($insertType == "COMPLETE") { - $outputBuffer .= "INSERT INTO `$t` (`$columnImplosion`) VALUES "; - } else { - if (!$firstLine) - $outputBuffer .= ",\r\n"; - } - - $outputBuffer .= "("; - - $first = true; - - for ($i=0; $iescapeString($currentData) . "'"; - } - - $first = false; - } - - $outputBuffer .= ")"; - - if ($insertType == "COMPLETE") - $outputBuffer .= ";\r\n"; - - $firstLine = false; - - } - - if ($insertType == "COMPACT") - $outputBuffer .= ";\r\n"; - - } else { - $outputBuffer .= "-- [" . sprintf(__("Table `%s` is empty"), $t) . "]\r\n"; - } - - } else if ($conn->getAdapter() == "sqlite") { - - $dataSQL = $conn->query("SELECT * FROM '$t'"); - - // put the column names in an array - if ($conn->isResultSet($structureSQL)) { - foreach ($structureSQL as $structureRow) { - $columnList[] = $structureRow[0]; - $type[] = $structureRow[1]; - } - } - - $columnImplosion = implode("', '", $columnList); - - if ($conn->isResultSet($dataSQL)) { - - $firstLine = true; - - while ($dataRow = $conn->fetchAssoc($dataSQL)) { - - $outputBuffer .= "INSERT INTO '$t' ('$columnImplosion') VALUES ("; - - $first = true; - - for ($i=0; $iescapeString($currentData) . "'"; - - $first = false; - } - - $outputBuffer .= ");\r\n"; - - $firstLine = false; - - } - - } else { - $outputBuffer .= "-- [" . sprintf(__("Table `%s` is empty"), $t) . "]\r\n"; - } - - } - } - - $outputBuffer .= "\r\n"; - - } else if ($format == "CSV") { - - if (isset($printFieldnames)) { - $structureSQL = $conn->describeTable($t); - - if ($conn->isResultSet($structureSQL)) { - $first = true; - - if ($conn->getAdapter() == "mysql") { - - while ($structureRow = $conn->fetchArray($structureSQL)) { - if (!$first) - $outputBuffer .= $delimiter; - - $outputBuffer .= "\"" . $structureRow[0] . "\""; - - $first = false; - } - - } else if ($conn->getAdapter() == "sqlite") { - - foreach ($structureSQL as $structureRow) { - if (!$first) - $outputBuffer .= $delimiter; - - $outputBuffer .= "\"" . $structureRow[0] . "\""; - - $first = false; - } - - } - - $outputBuffer .= "\r\n"; - } - } - - if ($conn->getAdapter() == "mysql") { - $dataSQL = $conn->query("SELECT * FROM `$t`"); - } else if ($conn->getAdapter() == "sqlite") { - $dataSQL = $conn->query("SELECT * FROM '$t'"); - } - - if ($conn->isResultSet($dataSQL)) { - while ($dataRow = $conn->fetchArray($dataSQL)) { - $data = array(); - foreach ($dataRow as $each) { - $data[] = "\"" . formatDataForCSV($each) . "\""; - } - - $dataLine = implode($delimiter, $data); - - $outputBuffer .= $dataLine . "\r\n"; - } - } - - } - - } - - } - - $outputBuffer = trim($outputBuffer); - - if ($outputBuffer) { - if ($output == "BROWSER") { - echo "
"; - echo "" . __("Results:") . " [" . __("Select all") . "]"; - echo ""; - echo "
"; - } else { - - if (!$handle = @fopen($outputFile, "w")) { - $error = __("The file could not be opened") . "."; - } else { - if (fwrite($handle, $outputBuffer) === false) { - $error = __("Could not write to file") . "."; - } else { - echo '
'; - echo __("Successfully wrote content to file") . '. ' . __("Download") . '
' . __("Note") . ': ' . __("If this is a public server, you should delete this file from the server after you download it") . '.
'; - } - } - - @fclose($handle); - - } - } - - } -} - -if (isset($error)) { - echo '
' . $error . '
'; -} - -?> - -
- -

- -
- - - - - - - getAdapter() != "sqlite") { - ?> - - - - - - - - - - - -
:
  /
- -
:
  /
- -
: -
- -
- -
'; - - ?> - - > - - - - - getAdapter() == "mysql") { - - ?> - - - - - - - - > - - - - - - - - - - -
- - - - - - - - - - - - -
- . -
: -
- " style="vertical-align: middle; margin-left: 5px" /> -
" />
- - - + + +*/ + +include "functions.php"; + +loginCheck(); + +if ($_POST) { + + $outputBuffer = ""; + + if (isset($db)) { + $dbs[] = $db; + + if (isset($table)) + $tables[] = $table; + else if (isset($_POST['EXPORTTABLE'])) + $tables = $_POST['EXPORTTABLE']; + } else { + if (isset($_POST['EXPORTDB'])) + $dbs = $_POST['EXPORTDB']; + $exportDb = true; + } + + if (isset($_POST['FORMAT'])) + $format = strtoupper($_POST['FORMAT']); + + if (isset($_POST['STRUCTURE'])) + $exportStructure = $_POST['STRUCTURE']; + + if (isset($_POST['DATA'])) + $exportData = $_POST['DATA']; + + if (isset($_POST['DELIMITER'])) + $delimiter = $_POST['DELIMITER']; + + if (isset($_POST['FIELDNAMES'])) + $printFieldnames = $_POST['FIELDNAMES']; + + if (isset($_POST['INSERTTYPE'])) + $insertType = $_POST['INSERTTYPE']; + + if (isset($_POST['OUTPUT'])) + $output = $_POST['OUTPUT']; + + if (isset($_POST['OUTPUTFILETEXT'])) { + $outputFile = "exports/" . basename($_POST['OUTPUTFILETEXT']); + } + + if (!isset($delimiter) || $delimiter == "TAB") + $delimiter = "\t"; + else if ($delimiter == "SEMICOLON") + $delimiter = ";"; + else if ($delimiter == "SPACE") + $delimiter = " "; + else + $delimiter = ","; + + // for the next three - it has to be one or the other + // this way, if we get fed garbage, just go with a default + if (!isset($format) || $format != "CSV") + $format = "SQL"; + + if (!isset($output) || $output != "FILE" || !isset($outputFile)) + $output = "BROWSER"; + + if (!isset($insertType) || $insertType != "COMPLETE") + $insertType = "COMPACT"; + + if (isset($format) && $format == "SQL" && !isset($exportStructure) && !isset($exportData)) { + $error = __("You must export either structure, data, or both") . "."; + } else if (!isset($dbs)) { + $error = __("Please select the databases that you would like to export") . "."; + } else if (isset($db) && !isset($tables)) { + $error = __("Please select the tables that you would like to export") . "."; + } else { + + if ($format == "SQL") { + + $version = $conn->getVersion(); + + $outputBuffer .= "--\r\n"; + + if ($conn->getAdapter() == "mysql") + $outputBuffer .= "-- MySQL " . $version . "\r\n"; + else if ($conn->getAdapter() == "sqlite") + $outputBuffer .= "-- SQLite " . $version . "\r\n"; + + $outputBuffer .= "-- " . date("r") . "\r\n"; + $outputBuffer .= "--\r\n\r\n"; + } + + foreach ($dbs as $d) { + + $conn->selectDB($d); + + // this checks to see if we are exporting an entire db with all tables + if (isset($exportDb) && $exportDb == true) { + + if ($format == "SQL") { + + $outputBuffer .= "CREATE DATABASE `$d`"; + + if ($conn->hasCharsetSupport()) + { + $currentChar = ""; + $currentCharSql = $conn->query("SHOW VARIABLES LIKE 'character_set_database'"); + + if ($conn->isResultSet($currentCharSql)) { + $currentChar = $conn->result($currentCharSql, 0, "Value"); + + $outputBuffer .= " DEFAULT CHARSET " . $currentChar; + } + } + + $outputBuffer .= ";\r\n\r\n"; + + $outputBuffer .= "USE `$d`;\r\n\r\n"; + + } + + $tableSql = $conn->listTables(); + + $tables = ""; + + if ($conn->isResultSet($tableSql)) { + while ($tableRow = $conn->fetchArray($tableSql)) { + $tables[] = $tableRow[0]; + } + } + } + + foreach ($tables as $t) { + + if ($format == "SQL") { + + if ($conn->getAdapter() == "mysql") + $structureSQL = $conn->query("SHOW FULL FIELDS FROM `$t`"); + else + $structureSQL = $conn->describeTable($t); + + $tableEngine = ""; + $tableCharset = ""; + $autoIncrement = ""; + + if (isset($exportStructure)) { + + if ($conn->isResultSet($structureSQL)) { + + if ($conn->getAdapter() == "mysql") { + + $outputBuffer .= "CREATE TABLE `$t` ("; + + $infoSql = $conn->query("SHOW TABLE STATUS LIKE '$t'"); + + if ($conn->isResultSet($infoSql) == 1) { + + $infoRow = $conn->fetchAssoc($infoSql); + + $tableEngine = (array_key_exists("Type", $infoRow)) ? $infoRow['Type'] : $infoRow['Engine']; + + if (array_key_exists('Collation', $infoRow) && isset($collationList)) { + $tableCharset = $collationList[$infoRow['Collation']]; + } + + if (array_key_exists('Auto_increment', $infoRow)) + { + $autoIncrement = $infoRow['Auto_increment']; + } + } + + } else if ($conn->getAdapter() == "sqlite") { + + $outputBuffer .= "CREATE TABLE '$t' ("; + } + + $first = true; + + if ($conn->getAdapter() == "mysql") { + + while ($structureRow = $conn->fetchassoc($structureSQL)) { + + if (!$first) + $outputBuffer .= ","; + + $outputBuffer .= "\r\n `" . $structureRow['Field'] . "` " . $structureRow['Type']; + + if (isset($collationList) && isset($structureRow['Collation']) && $structureRow['Collation'] != "NULL" && !is_null($structureRow['Collation'])) { + if ($collationList[$structureRow['Collation']] != $tableCharset) { + $outputBuffer .= " CHARSET " . $collationList[$structureRow['Collation']]; + } + } + + if (isset($structureRow['Null']) && $structureRow['Null'] != "YES") + $outputBuffer .= " not null"; + + if (isset($structureRow['Default']) && $structureRow['Default'] == "CURRENT_TIMESTAMP") { + $outputBuffer .= " default CURRENT_TIMESTAMP"; + } else if (isset($structureRow['Default']) && $structureRow['Default'] != "") { + $outputBuffer .= " default '" . $structureRow['Default'] . "'"; + } + + if (isset($structureRow['Extra']) && $structureRow['Extra'] != "") + $outputBuffer .= " " . $structureRow['Extra']; + + $first = false; + } + + } else if ($conn->getAdapter() == "sqlite") { + + foreach ($structureSQL as $structureRow) { + + if (!$first) + $outputBuffer .= ","; + + $outputBuffer .= "\r\n " . $structureRow[0] . " " . $structureRow[1]; + + $first = false; + } + + } + + // dont forget about the keys + if ($conn->getAdapter() == "mysql") { + $keySQL = $conn->query("SHOW INDEX FROM `$t`"); + + if ($conn->isResultSet($keySQL)) { + $currentKey = ""; + while ($keyRow = $conn->fetchAssoc($keySQL)) { + // if this is the start of a key + if ($keyRow['Key_name'] != $currentKey) { + // finish off the last key first, if necessary + if ($currentKey != "") + $outputBuffer .= ")"; + + if ($keyRow['Key_name'] == "PRIMARY") + $outputBuffer .= ",\r\n PRIMARY KEY ("; + elseif ($keyRow['Non_unique'] == "0") + $outputBuffer .= ",\r\n UNIQUE KEY ("; + else + $outputBuffer .= ",\r\n KEY `" . $keyRow['Key_name'] . "` ("; + + $outputBuffer .= "`" . $keyRow['Column_name'] . "`"; + } else { + $outputBuffer .= ",`" . $keyRow['Column_name'] . "`"; + } + + $currentKey = $keyRow['Key_name']; + } + + if (isset($currentKey) && $currentKey != "") + $outputBuffer .= ")"; + } + } + + $outputBuffer .= "\r\n)"; + + if ($conn->getAdapter() == "mysql") { + if ($tableEngine) { + $outputBuffer .= ' ENGINE=' . $tableEngine; + } + + if ($tableCharset) { + $outputBuffer .= ' DEFAULT CHARSET=' . $tableCharset; + } + + if ($autoIncrement) + { + $outputBuffer .= ' AUTO_INCREMENT=' . $autoIncrement; + } + } + + $outputBuffer .= ";\r\n\r\n"; + } + } + + if ($conn->getAdapter() == "mysql") + $structureSQL = $conn->query("SHOW FULL FIELDS FROM `$t`"); + else + $structureSQL = $conn->describeTable($t); + + if (isset($exportData)) { + + $columnList = array(); + + if ($conn->getAdapter() == "mysql") { + + $dataSQL = $conn->query("SELECT * FROM `$t`"); + + // put the column names in an array + if ($conn->isResultSet($structureSQL)) { + while ($structureRow = $conn->fetchAssoc($structureSQL)) { + $columnList[] = $structureRow['Field']; + $type[] = $structureRow['Type']; + } + } + + $columnImplosion = implode("`, `", $columnList); + + if ($conn->isResultSet($dataSQL)) { + + if ($insertType == "COMPACT") + $outputBuffer .= "INSERT INTO `$t` (`$columnImplosion`) VALUES \r\n"; + + $firstLine = true; + + while ($dataRow = $conn->fetchAssoc($dataSQL)) { + + if ($insertType == "COMPLETE") { + $outputBuffer .= "INSERT INTO `$t` (`$columnImplosion`) VALUES "; + } else { + if (!$firstLine) + $outputBuffer .= ",\r\n"; + } + + $outputBuffer .= "("; + + $first = true; + + for ($i=0; $iescapeString($currentData) . "'"; + } + + $first = false; + } + + $outputBuffer .= ")"; + + if ($insertType == "COMPLETE") + $outputBuffer .= ";\r\n"; + + $firstLine = false; + + } + + if ($insertType == "COMPACT") + $outputBuffer .= ";\r\n"; + + } else { + $outputBuffer .= "-- [" . sprintf(__("Table `%s` is empty"), $t) . "]\r\n"; + } + + } else if ($conn->getAdapter() == "sqlite") { + + $dataSQL = $conn->query("SELECT * FROM '$t'"); + + // put the column names in an array + if ($conn->isResultSet($structureSQL)) { + foreach ($structureSQL as $structureRow) { + $columnList[] = $structureRow[0]; + $type[] = $structureRow[1]; + } + } + + $columnImplosion = implode("', '", $columnList); + + if ($conn->isResultSet($dataSQL)) { + + $firstLine = true; + + while ($dataRow = $conn->fetchAssoc($dataSQL)) { + + $outputBuffer .= "INSERT INTO '$t' ('$columnImplosion') VALUES ("; + + $first = true; + + for ($i=0; $iescapeString($currentData) . "'"; + + $first = false; + } + + $outputBuffer .= ");\r\n"; + + $firstLine = false; + + } + + } else { + $outputBuffer .= "-- [" . sprintf(__("Table `%s` is empty"), $t) . "]\r\n"; + } + + } + } + + $outputBuffer .= "\r\n"; + + } else if ($format == "CSV") { + + if (isset($printFieldnames)) { + $structureSQL = $conn->describeTable($t); + + if ($conn->isResultSet($structureSQL)) { + $first = true; + + if ($conn->getAdapter() == "mysql") { + + while ($structureRow = $conn->fetchArray($structureSQL)) { + if (!$first) + $outputBuffer .= $delimiter; + + $outputBuffer .= "\"" . $structureRow[0] . "\""; + + $first = false; + } + + } else if ($conn->getAdapter() == "sqlite") { + + foreach ($structureSQL as $structureRow) { + if (!$first) + $outputBuffer .= $delimiter; + + $outputBuffer .= "\"" . $structureRow[0] . "\""; + + $first = false; + } + + } + + $outputBuffer .= "\r\n"; + } + } + + if ($conn->getAdapter() == "mysql") { + $dataSQL = $conn->query("SELECT * FROM `$t`"); + } else if ($conn->getAdapter() == "sqlite") { + $dataSQL = $conn->query("SELECT * FROM '$t'"); + } + + if ($conn->isResultSet($dataSQL)) { + while ($dataRow = $conn->fetchArray($dataSQL)) { + $data = array(); + foreach ($dataRow as $each) { + $data[] = "\"" . formatDataForCSV($each) . "\""; + } + + $dataLine = implode($delimiter, $data); + + $outputBuffer .= $dataLine . "\r\n"; + } + } + + } + + } + + } + + $outputBuffer = trim($outputBuffer); + + if ($outputBuffer) { + if ($output == "BROWSER") { + echo "
"; + echo "" . __("Results:") . " [" . __("Select all") . "]"; + echo ""; + echo "
"; + } else { + + if (!$handle = @fopen($outputFile, "w")) { + $error = __("The file could not be opened") . "."; + } else { + if (fwrite($handle, $outputBuffer) === false) { + $error = __("Could not write to file") . "."; + } else { + echo '
'; + echo __("Successfully wrote content to file") . '. ' . __("Download") . '
' . __("Note") . ': ' . __("If this is a public server, you should delete this file from the server after you download it") . '.
'; + } + } + + @fclose($handle); + + } + } + + } +} + +if (isset($error)) { + echo '
' . $error . '
'; +} + +?> + +
+ +

+ +
+ + + + + + + getAdapter() != "sqlite") { + ?> + + + + + + + + + + + +
:
  /
+ +
:
  /
+ +
: +
+ +
+ +
'; + + ?> + + > + + + + + getAdapter() == "mysql") { + + ?> + + + + + + + + > + + + + + + + + + + +
+ + + + + + + + + + + + +
+ . +
: +
+ " style="vertical-align: middle; margin-left: 5px" /> +
" />
+ + + \ No newline at end of file diff --git a/htdocs/sqlbuddy/functions.php b/htdocs/sqlbuddy/functions.php index e0d8b748b..775fd44fa 100755 --- a/htdocs/sqlbuddy/functions.php +++ b/htdocs/sqlbuddy/functions.php @@ -1,559 +1,568 @@ - - -*/ - -error_reporting(E_ALL); - -if (function_exists('date_default_timezone_set')) - date_default_timezone_set('Greenwich'); - -if (!session_id()) - session_start(); - -define("MAIN_DIR", dirname(__FILE__) . "/"); -define("INCLUDES_DIR", MAIN_DIR . "includes/"); - -include MAIN_DIR . "config.php"; -include INCLUDES_DIR . "types.php"; -include INCLUDES_DIR . "class/GetTextReader.php"; - -if (version_compare(PHP_VERSION, "5.0.0", "<")) - include INCLUDES_DIR . "class/Sql-php4.php"; -else - include INCLUDES_DIR . "class/Sql.php"; - -define("VERSION_NUMBER", "1.3.2"); -define("PREVIEW_CHAR_SIZE", 75); - -$adapterList[] = "mysql"; - -if (function_exists("sqlite_open") || (class_exists("PDO") && in_array("sqlite", PDO::getAvailableDrivers()))) { - $adapterList[] = "sqlite"; -} - -$cookieLength = time() + (60*24*60*60); - -$langList['ms_ID'] = "Bahasa Melayu"; -$langList['ca_AD'] = "Català"; -$langList['cs_CZ'] = "Čeština"; -$langList['sr_RS'] = "Српски ћирилица"; -$langList['da_DK'] = "Danish"; -$langList['de_DE'] = "Deutsch"; -$langList['en_US'] = "English"; -$langList['es_ES'] = "Español"; -$langList['es_AR'] = "Español (Argentina)"; -$langList['eo_EO'] = "Esperanto"; -$langList['fr_FR'] = "Français"; -$langList['gl_ES'] = "Galego"; -$langList['id_ID'] = "Indonesian"; -$langList['it_IT'] = "Italiano"; -$langList['he_IL'] = "Ivrit"; -$langList['lo_LA'] = "Lao"; -$langList['lv_LV'] = "Latviešu"; -$langList['hu_HU'] = "Magyar"; -$langList['nl_NL'] = "Nederlands"; -$langList['pl_PL'] = "Polski"; -$langList['pt_BR'] = "Português (Brasil)"; -$langList['pt_PT'] = "Português (Portugal)"; -$langList['ru_RU'] = "Русский"; -$langList['ro_RO'] = "Română"; -$langList['sk_SK'] = "Slovenčina"; -$langList['sl_SL'] = "Slovenščina"; -$langList['sp_RS'] = "Srpski"; -$langList['fi_FI'] = "Suomi"; -$langList['sv_SE'] = "Svenska"; -$langList['tl_PH'] = "Tagalog"; -$langList['vi_VN'] = "Tiếng Việt"; -$langList['tr_TR'] = "Türkçe"; -$langList['uk_UA'] = "Українська"; -$langList['ar_DZ'] = "العربية"; -$langList['fa_IR'] = "فارسی"; -$langList['zh_CN'] = "中文 (简体)"; -$langList['zh_TW'] = "中文 (繁體)"; -$langList['ja_JP'] = "日本語"; - -if (isset($_COOKIE['sb_lang']) && array_key_exists($_COOKIE['sb_lang'], $langList)) { - $lang = preg_replace("/[^a-z0-9_]/i", "", $_COOKIE['sb_lang']); -} else { - $lang = "en_US"; -} - -if ($lang != "en_US") { - // extend the cookie length - setcookie("sb_lang", $lang, $cookieLength); -} else if (isset($_COOKIE['sb_lang'])) { - // cookie not needed for en_US - setcookie("sb_lang", "", time() - 10000); -} - -$themeList["classic"] = "Classic"; -$themeList["bittersweet"] = "Bittersweet"; - -if (isset($_COOKIE['sb_theme'])) { - $currentTheme = preg_replace("/[^a-z0-9_]/i", "", $_COOKIE['sb_theme']); - - if (array_key_exists($currentTheme, $themeList)) { - $theme = $currentTheme; - - // extend the cookie length - setcookie("sb_theme", $theme, $cookieLength); - } else { - $theme = "bittersweet"; - setcookie("sb_theme", "", time() - 10000); - } -} else { - $theme = "bittersweet"; -} - -$gt = new GetTextReader($lang . ".pot"); - -if (isset($_SESSION['SB_LOGIN_STRING'])) { - $user = (isset($_SESSION['SB_LOGIN_USER'])) ? $_SESSION['SB_LOGIN_USER'] : ""; - $pass = (isset($_SESSION['SB_LOGIN_PASS'])) ? $_SESSION['SB_LOGIN_PASS'] : ""; - $conn = new SQL($_SESSION['SB_LOGIN_STRING'], $user, $pass); -} - -// unique identifer for this session, to validate ajax requests. -// document root is included because it is likely a difficult value -// for potential attackers to guess -$requestKey = substr(md5(session_id() . $_SERVER["DOCUMENT_ROOT"]), 0, 16); - -if (isset($conn) && $conn->isConnected()) { - if (isset($_GET['db'])) - $db = $conn->escapeString($_GET['db']); - - if (isset($_GET['table'])) - $table = $conn->escapeString($_GET['table']); - - if ($conn->hasCharsetSupport()) { - - $charsetSql = $conn->listCharset(); - if ($conn->isResultSet($charsetSql)) { - while ($charsetRow = $conn->fetchAssoc($charsetSql)) { - $charsetList[] = $charsetRow['Charset']; - } - } - - $collationSql = $conn->listCollation(); - if ($conn->isResultSet($collationSql)) { - while ($collationRow = $conn->fetchAssoc($collationSql)) { - $collationList[$collationRow['Collation']] = $collationRow['Charset']; - } - } - } -} - -// undo magic quotes, if necessary -if (get_magic_quotes_gpc()) { - $_GET = stripslashesFromArray($_GET); - $_POST = stripslashesFromArray($_POST); - $_COOKIE = stripslashesFromArray($_COOKIE); - $_REQUEST = stripslashesFromArray($_REQUEST); -} - -function stripslashesFromArray($value) { - $value = is_array($value) ? - array_map('stripslashesFromArray', $value) : - stripslashes($value); - - return $value; -} - -function loginCheck($validateReq = true) { - if (!isset($_SESSION['SB_LOGIN'])){ - if (isset($_GET['ajaxRequest'])) - redirect("login.php?timeout=1"); - else - redirect("login.php"); - exit; - } - if ($validateReq) { - if (!validateRequest()) { - exit; - } - } - - startOutput(); -} - -function redirect($url) { - if (isset($_GET['ajaxRequest']) || headers_sent()) { - global $requestKey; - ?> - - isConnected()) { - $conn->disconnect(); - unset($conn); - } -} - -function outputPage() { - -global $requestKey; -global $sbconfig; -global $conn; -global $lang; - -?> - - - - SQL Buddy - - " media="all" /> - " media="all" /> - " media="print" /> - " media="all" /> - - - - - - - -
- - -
- -
-
-
    - getAdapter() != "sqlite") { - - ?> -
  • -
  • -
  • -
  • -
  • - -
  • -
  • -
  • -
  • - -
- -
-
    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    - -
    -
    - - - - - - -
    -

    -

    -
    - - - -
    -

    -

    -
    - - PREVIEW_CHAR_SIZE) { - $text = utf8_substr($text, 0, PREVIEW_CHAR_SIZE) . " [...]"; - } - return $text; -} - -function formatDataForCSV($text) { - $text = str_replace('"', '""', $text); - return $text; -} - -function splitQueryText($query) { - // the regex needs a trailing semicolon - $query = trim($query); - - if (substr($query, -1) != ";") - $query .= ";"; - - // i spent 3 days figuring out this line - preg_match_all("/(?>[^;']|(''|(?>'([^']|\\')*[^\\\]')))+;/ixU", $query, $matches, PREG_SET_ORDER); - - $querySplit = ""; - - foreach ($matches as $match) { - // get rid of the trailing semicolon - $querySplit[] = substr($match[0], 0, -1); - } - - return $querySplit; -} - -function memoryFormat($bytes) { - if ($bytes < 1024) - $dataString = $bytes . " B"; - else if ($bytes < (1024 * 1024)) - $dataString = round($bytes / 1024) . " KB"; - else if ($bytes < (1024 * 1024 * 1024)) - $dataString = round($bytes / (1024 * 1024)) . " MB"; - else - $dataString = round($bytes / (1024 * 1024 * 1024)) . " GB"; - - return $dataString; -} - -function themeFile($filename) { - global $theme; - return smartCaching("themes/" . $theme . "/" . $filename); -} - -function smartCaching($filename) { - return $filename . "?ver=" . str_replace(".", "_", VERSION_NUMBER); -} - -function __($t) { - global $gt; - return $gt->getTranslation($t); -} - -function __p($singular, $plural, $count) { - global $gt; - if ($count == 1) { - return $gt->getTranslation($singular); - } else { - return $gt->getTranslation($plural); - } -} - -function utf8_substr($str, $from, $len) { -# utf8 substr -# www.yeap.lv - return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. - '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s', - '$1',$str); -} - -function utf8_strlen($str) { - $i = 0; - $count = 0; - $len = strlen ($str); - while ($i < $len) { - $chr = ord ($str[$i]); - $count++; - $i++; - if ($i >= $len) - break; - - if ($chr & 0x80) { - $chr <<= 1; - while ($chr & 0x80) { - $i++; - $chr <<= 1; - } - } - } - return $count; -} - -function microtime_float() { - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec + (float)$sec); -} - + + +*/ + +error_reporting(E_ALL); + +if (function_exists('date_default_timezone_set')) + date_default_timezone_set('Greenwich'); + +if (!session_id()) + session_start(); + +define("MAIN_DIR", dirname(__FILE__) . "/"); +define("INCLUDES_DIR", MAIN_DIR . "includes/"); + +include MAIN_DIR . "config.php"; +include INCLUDES_DIR . "types.php"; +include INCLUDES_DIR . "class/GetTextReader.php"; + +if (version_compare(PHP_VERSION, "5.0.0", "<")) + include INCLUDES_DIR . "class/Sql-php4.php"; +else + include INCLUDES_DIR . "class/Sql.php"; + +define("VERSION_NUMBER", "1.3.3"); +define("PREVIEW_CHAR_SIZE", 75); + +$adapterList[] = "mysql"; + +if (function_exists("sqlite_open") || (class_exists("PDO") && in_array("sqlite", PDO::getAvailableDrivers()))) { + $adapterList[] = "sqlite"; +} + +$cookieLength = time() + (60*24*60*60); + +$langList['id_ID'] = "Bahasa Indonesia"; +$langList['ms_ID'] = "Bahasa Melayu"; +$langList['ca_AD'] = "Català"; +$langList['cs_CZ'] = "Čeština"; +$langList['sr_RS'] = "Српски ћирилица"; +$langList['da_DK'] = "Dansk"; +$langList['de_DE'] = "Deutsch"; +$langList['et_EE'] = "Eesti keel"; +$langList['en_US'] = "English"; +$langList['es_ES'] = "Español"; +$langList['es_AR'] = "Español (Argentina)"; +$langList['eo_EO'] = "Esperanto"; +$langList['fr_FR'] = "Français"; +$langList['gl_ES'] = "Galego"; +$langList['hr_HR'] = "Hrvatski"; +$langList['it_IT'] = "Italiano"; +$langList['ko_KR'] = "한국어"; +$langList['lo_LA'] = "Lao"; +$langList['lv_LV'] = "Latviešu"; +$langList['hu_HU'] = "Magyar"; +$langList['nl_NL'] = "Nederlands"; +$langList['no_NO'] = "Norsk"; +$langList['pl_PL'] = "Polski"; +$langList['pt_BR'] = "Português (Brasil)"; +$langList['pt_PT'] = "Português (Portugal)"; +$langList['ru_RU'] = "Русский"; +$langList['ro_RO'] = "Română"; +$langList['sq_AL'] = "Shqip"; +$langList['sk_SK'] = "Slovenčina"; +$langList['sl_SL'] = "Slovenščina"; +$langList['sp_RS'] = "Srpski"; +$langList['fi_FI'] = "Suomi"; +$langList['sv_SE'] = "Svenska"; +$langList['tl_PH'] = "Tagalog"; +$langList['vi_VN'] = "Tiếng Việt"; +$langList['tr_TR'] = "Türkçe"; +$langList['uk_UA'] = "Українська"; +$langList['ar_DZ'] = "العربية"; +$langList['fa_IR'] = "فارسی"; +$langList['he_IL'] = "עִבְרִית"; +$langList['bg_BG'] = "български език"; +$langList['bn_BD'] = "বাংলা"; +$langList['el_GR'] = "ελληνικά"; +$langList['th_TH'] = "ภาษาไทย"; +$langList['zh_CN'] = "中文 (简体)"; +$langList['zh_TW'] = "中文 (繁體)"; +$langList['ja_JP'] = "日本語"; + +if (isset($_COOKIE['sb_lang']) && array_key_exists($_COOKIE['sb_lang'], $langList)) { + $lang = preg_replace("/[^a-z0-9_]/i", "", $_COOKIE['sb_lang']); +} else { + $lang = "en_US"; +} + +if ($lang != "en_US") { + // extend the cookie length + setcookie("sb_lang", $lang, $cookieLength); +} else if (isset($_COOKIE['sb_lang'])) { + // cookie not needed for en_US + setcookie("sb_lang", "", time() - 10000); +} + +$themeList["classic"] = "Classic"; +$themeList["bittersweet"] = "Bittersweet"; + +if (isset($_COOKIE['sb_theme'])) { + $currentTheme = preg_replace("/[^a-z0-9_]/i", "", $_COOKIE['sb_theme']); + + if (array_key_exists($currentTheme, $themeList)) { + $theme = $currentTheme; + + // extend the cookie length + setcookie("sb_theme", $theme, $cookieLength); + } else { + $theme = "bittersweet"; + setcookie("sb_theme", "", time() - 10000); + } +} else { + $theme = "bittersweet"; +} + +$gt = new GetTextReader($lang . ".pot"); + +if (isset($_SESSION['SB_LOGIN_STRING'])) { + $user = (isset($_SESSION['SB_LOGIN_USER'])) ? $_SESSION['SB_LOGIN_USER'] : ""; + $pass = (isset($_SESSION['SB_LOGIN_PASS'])) ? $_SESSION['SB_LOGIN_PASS'] : ""; + $conn = new SQL($_SESSION['SB_LOGIN_STRING'], $user, $pass); +} + +// unique identifer for this session, to validate ajax requests. +// document root is included because it is likely a difficult value +// for potential attackers to guess +$requestKey = substr(md5(session_id() . $_SERVER["DOCUMENT_ROOT"]), 0, 16); + +if (isset($conn) && $conn->isConnected()) { + if (isset($_GET['db'])) + $db = $conn->escapeString($_GET['db']); + + if (isset($_GET['table'])) + $table = $conn->escapeString($_GET['table']); + + if ($conn->hasCharsetSupport()) { + + $charsetSql = $conn->listCharset(); + if ($conn->isResultSet($charsetSql)) { + while ($charsetRow = $conn->fetchAssoc($charsetSql)) { + $charsetList[] = $charsetRow['Charset']; + } + } + + $collationSql = $conn->listCollation(); + if ($conn->isResultSet($collationSql)) { + while ($collationRow = $conn->fetchAssoc($collationSql)) { + $collationList[$collationRow['Collation']] = $collationRow['Charset']; + } + } + } +} + +// undo magic quotes, if necessary +if (get_magic_quotes_gpc()) { + $_GET = stripslashesFromArray($_GET); + $_POST = stripslashesFromArray($_POST); + $_COOKIE = stripslashesFromArray($_COOKIE); + $_REQUEST = stripslashesFromArray($_REQUEST); +} + +function stripslashesFromArray($value) { + $value = is_array($value) ? + array_map('stripslashesFromArray', $value) : + stripslashes($value); + + return $value; +} + +function loginCheck($validateReq = true) { + if (!isset($_SESSION['SB_LOGIN'])){ + if (isset($_GET['ajaxRequest'])) + redirect("login.php?timeout=1"); + else + redirect("login.php"); + exit; + } + if ($validateReq) { + if (!validateRequest()) { + exit; + } + } + + startOutput(); +} + +function redirect($url) { + if (isset($_GET['ajaxRequest']) || headers_sent()) { + global $requestKey; + ?> + + isConnected()) { + $conn->disconnect(); + unset($conn); + } +} + +function outputPage() { + +global $requestKey; +global $sbconfig; +global $conn; +global $lang; + +?> + + + + SQL Buddy + + " media="all" /> + " media="all" /> + " media="print" /> + " media="all" /> + + + + + + + +
    + + +
    + +
    +
    +
      + getAdapter() != "sqlite") { + + ?> +
    • +
    • +
    • +
    • +
    • + +
    • +
    • +
    • +
    • + +
    + +
    +
      +
      +
      +
      + +
      +
      +
      +
      +
      + +
      + +
      +
      + + + + + + +
      +

      +

      +
      + + + +
      +

      +

      +
      + + PREVIEW_CHAR_SIZE) { + $text = utf8_substr($text, 0, PREVIEW_CHAR_SIZE) . " [...]"; + } + return $text; +} + +function formatDataForCSV($text) { + $text = str_replace('"', '""', $text); + return $text; +} + +function splitQueryText($query) { + // the regex needs a trailing semicolon + $query = trim($query); + + if (substr($query, -1) != ";") + $query .= ";"; + + // i spent 3 days figuring out this line + preg_match_all("/(?>[^;']|(''|(?>'([^']|\\')*[^\\\]')))+;/ixU", $query, $matches, PREG_SET_ORDER); + + $querySplit = ""; + + foreach ($matches as $match) { + // get rid of the trailing semicolon + $querySplit[] = substr($match[0], 0, -1); + } + + return $querySplit; +} + +function memoryFormat($bytes) { + if ($bytes < 1024) + $dataString = $bytes . " B"; + else if ($bytes < (1024 * 1024)) + $dataString = round($bytes / 1024) . " KB"; + else if ($bytes < (1024 * 1024 * 1024)) + $dataString = round($bytes / (1024 * 1024)) . " MB"; + else + $dataString = round($bytes / (1024 * 1024 * 1024)) . " GB"; + + return $dataString; +} + +function themeFile($filename) { + global $theme; + return smartCaching("themes/" . $theme . "/" . $filename); +} + +function smartCaching($filename) { + return $filename . "?ver=" . str_replace(".", "_", VERSION_NUMBER); +} + +function __($t) { + global $gt; + return $gt->getTranslation($t); +} + +function __p($singular, $plural, $count) { + global $gt; + if ($count == 1) { + return $gt->getTranslation($singular); + } else { + return $gt->getTranslation($plural); + } +} + +function utf8_substr($str, $from, $len) { +# utf8 substr +# www.yeap.lv + return preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'. + '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s', + '$1',$str); +} + +function utf8_strlen($str) { + $i = 0; + $count = 0; + $len = strlen ($str); + while ($i < $len) { + $chr = ord ($str[$i]); + $count++; + $i++; + if ($i >= $len) + break; + + if ($chr & 0x80) { + $chr <<= 1; + while ($chr & 0x80) { + $i++; + $chr <<= 1; + } + } + } + return $count; +} + +function microtime_float() { + list($usec, $sec) = explode(" ", microtime()); + return ((float)$usec + (float)$sec); +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/home.php b/htdocs/sqlbuddy/home.php index 139befefe..7b9720e77 100755 --- a/htdocs/sqlbuddy/home.php +++ b/htdocs/sqlbuddy/home.php @@ -1,311 +1,311 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -?> - - - - - - - - - - - - - -getAdapter() != "sqlite") { - -?> - - - - - - - - - - - - - - - - - - + + +*/ + +include "functions.php"; + +loginCheck(); + +?> +
      -

      -
      - - getVersion(); - - if ($conn->getAdapter() == "mysql") { - - if (isset($_SESSION['SB_LOGIN_USER']) && $conn->getOptionValue("host")) { - $message = sprintf(__("You are connected to MySQL %s with the user %s."), $dbVersion, $_SESSION['SB_LOGIN_USER'] . "@" . $conn->getOptionValue("host")); - } - - } else if ($conn->getAdapter() == "sqlite") { - $message = sprintf(__("You are connected to %s."), "SQLite " . $dbVersion); - } - - echo "

      " . $message . "

      "; - - ?> - - - 0) { - $content = strip_tags($content); - - list($version, $notes) = explode("\n", $content, 2); - - ?> - - - - - - - - - - - - - -
      - : - - ")) { - echo '' . __("A new version of SQL Buddy is available!") . ' ' . __("Download") . ' »'; - } else { - echo __("There are no updates available") . "."; - } - - ?> -
      - : - - 0) { - - echo ''; - - } - - ?> -
      - : - - -
      - -
      -

      -
      - -
        -
      • -
      • -
      • -
      - -
      -

      -
      - -
      - - - - - - "; - echo ""; - echo ""; - echo ""; - } - - ?> - - - - -
      - : - - -
      "; - echo __("Charset") . ":"; - echo ""; - echo ""; - echo "
      - " /> -
      -
      - -
      -

      -
      - -

      - -
      -

      -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      a
      n
      e
      d
      r
      q
      f
      l
      g
      h
      o
      -
      + + + + + + + + + + + + +getAdapter() != "sqlite") { + +?> + + + + + + + + + + + + + + + + + +
      +

      +
      + + getVersion(); + + if ($conn->getAdapter() == "mysql") { + + if (isset($_SESSION['SB_LOGIN_USER']) && $conn->getOptionValue("host")) { + $message = sprintf(__("You are connected to MySQL %s with the user %s."), $dbVersion, $_SESSION['SB_LOGIN_USER'] . "@" . $conn->getOptionValue("host")); + } + + } else if ($conn->getAdapter() == "sqlite") { + $message = sprintf(__("You are connected to %s."), "SQLite " . $dbVersion); + } + + echo "

      " . $message . "

      "; + + ?> + + + 0) { + $content = strip_tags($content); + + list($version, $notes) = explode("\n", $content, 2); + + ?> + + + + + + + + + + + + + +
      + : + + ")) { + echo '' . __("A new version of SQL Buddy is available!") . ' ' . __("Download") . ' »'; + } else { + echo __("There are no updates available") . "."; + } + + ?> +
      + : + + 0) { + + echo ''; + + } + + ?> +
      + : + + +
      + +
      +

      +
      + +
        +
      • +
      • +
      • +
      + +
      +

      +
      + +
      + + + + + + "; + echo ""; + echo ""; + echo ""; + } + + ?> + + + + +
      + : + + +
      "; + echo __("Charset") . ":"; + echo ""; + echo ""; + echo "
      + " /> +
      +
      + +
      +

      +
      + +

      + +
      +

      +
      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      a
      n
      e
      d
      r
      q
      f
      l
      g
      h
      o
      +
      \ No newline at end of file diff --git a/htdocs/sqlbuddy/import.php b/htdocs/sqlbuddy/import.php index f4789419a..ee33e5fa7 100755 --- a/htdocs/sqlbuddy/import.php +++ b/htdocs/sqlbuddy/import.php @@ -1,88 +1,88 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -?> - -
      - - - -

      - -
      - - - - - - - - - - - - - - - - -
      .
      : - -
      : -
      - -
      - -
      - - - - - - - - - - - - - - - -
      " />
      - -
      - -
      - + + +*/ + +include "functions.php"; + +loginCheck(); + +?> + +
      + + + +

      + +
      + + + + + + + + + + + + + + + + +
      .
      : + +
      : +
      + +
      + +
      + + + + + + + + + + + + + + + +
      " />
      + +
      + +
      + \ No newline at end of file diff --git a/htdocs/sqlbuddy/includes/browse.php b/htdocs/sqlbuddy/includes/browse.php index 33ead330d..2246cc223 100755 --- a/htdocs/sqlbuddy/includes/browse.php +++ b/htdocs/sqlbuddy/includes/browse.php @@ -1,402 +1,402 @@ - - -*/ - -$totalRows = 0; -$insertCount = 0; -$queryTime = 0; - -$perPage = (isset($sbconfig) && array_key_exists("RowsPerPage", $sbconfig)) ? $sbconfig['RowsPerPage'] : 100; - -$displayLimit = 1000; - -$query = trim($query); - -if ($query) { - - if (!isset($queryTable)) { - $querySplit = splitQueryText($query); - } else { - $querySplit[] = $query; - } - - foreach ($querySplit as $q) { - $q = trim($q, "\n"); - if ($q != "") { - if (isset($queryTable)) { - $totalRows = $conn->tableRowCount($queryTable); - - if ($start > $totalRows) { - $start = 0; - } - - $q = "$q $sort LIMIT $start, $perPage"; - } - - $queryStartTime = microtime_float(); - $dataSql = $conn->query($q) or ($dbError[] = $conn->error()); - $queryFinishTime = microtime_float(); - $queryTime += round($queryFinishTime - $queryStartTime, 4); - - if ($conn->affectedRows($dataSql)) { - $insertCount += (int)($conn->affectedRows($dataSql)); - } - } - } - - if (!isset($queryTable)) { - $totalRows = (int)($conn->rowCount($dataSql)); - - // running rowCount on PDO resets the result set - // so we need to run the query again - if ($conn->getMethod() == "pdo") { - $dataSql = $conn->query($q); - } - } - -} - -//for the browse tab -if (isset($queryTable) && $conn->getAdapter() == "sqlite") { - $structure = $conn->describeTable($queryTable); - - if (sizeof($structure) > 0) { - foreach ($structure as $column) { - if (strpos($column[1], "primary key") > 0) { - $primaryKeys[] = $column[0]; - } - } - } -} else if (isset($queryTable) && $conn->getAdapter() == "mysql") { - $structureSql = $conn->describeTable($queryTable); - - if ($conn->isResultSet($structureSql)) { - while ($structureRow = $conn->fetchAssoc($structureSql)) { - $explosion = explode("(", $structureRow['Type'], 2); - - $tableTypes[] = $explosion[0]; - - if ($structureRow['Key'] == "PRI") { - $primaryKeys[] = $structureRow['Field']; - } - } - } -} - -echo '
      '; - -if (isset($dbError)) { - echo '
      ' . __("The following errors were reported") . ':'; - foreach ($dbError as $error) { - echo $error . "
      "; - } - echo '
      '; -} else { - - if (isset($totalRows) && $totalRows > 0) { - - if (isset($queryTable)) { - - echo ''; - echo ''; - echo ''; - - echo ''; - echo ''; - echo '
      '; - - if (isset($primaryKeys) && count($primaryKeys)) { - - echo __("Select") . ':  ' . __("All") . '  ' . __("None") . ''; - echo '     ' . __("With selected") . ':  ' . __("Edit") . '  ' . __("Delete") . ''; - - echo '       ' . __("Refresh") . ''; - - } else { - echo '[' . __("No primary key defined") . ']'; - } - - echo ''; - - $totalPages = ceil($totalRows / $perPage); - $currentPage = floor($start / $perPage) + 1; - - if ($currentPage > 1) { - echo '' . __("First") . ''; - echo '' . __("Prev") . ''; - } - - echo ''; - - if ($currentPage == 1) { - $startPage = 1; - $finishPage = 3; - - if ($finishPage > $totalPages) - $finishPage = $totalPages; - - } else if ($currentPage == $totalPages) { - $startPage = $totalPages - 2; - $finishPage = $totalPages; - - if ($startPage < 1) - $startPage = 1; - } else { - $startPage = $currentPage - 1; - $finishPage = $currentPage + 1; - } - - if ($startPage != $finishPage) { - for ($bnav=$startPage; $bnav<=$finishPage; $bnav++) { - echo '' . number_format($bnav) . ''; - } - } - - echo ''; - - if ($currentPage < $totalPages) { - echo '' . __("Next") . ''; - echo '' . __("Last") . ''; - } - - echo '
      '; - - } else { - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      '; - - printf(__p("Your query returned %d result.", "Your query returned %d results.", $totalRows), $totalRows); - echo " " . sprintf(__("(%.4f seconds)"), $queryTime); - - if ($totalRows > $displayLimit) - echo ' (' . sprintf(__("Note: To avoid crashing your browser, only the first %d results have been displayed"), $displayLimit) . '.)'; - echo '
      '; - } - - echo '
      '; - - if (isset($primaryKeys) && count($primaryKeys)) { - echo '
       
      '; - } - - echo '
      '; - - echo '
      '; - echo ''; - echo ''; - - if ($conn->isResultSet($dataSql)) { - $dataRow = $conn->fetchAssoc($dataSql); - $g = 0; - $numFields = 0; - - foreach ($dataRow as $key=>$value) { - - if ((isset($sortKey) && $sortKey == $key) && (isset($sortDir) && $sortDir == "ASC")) { - $outputDir = "DESC"; - } elseif (isset($sortKey) && $sortKey == $key) { - $outputDir = "ASC"; - } elseif (isset($sortDir) && $sortDir) { - $outputDir = $sortDir; - } else { - $outputDir = "ASC"; - } - echo ''; - echo ''; - $numFields++; - } - echo ''; - echo ''; - echo '
      '; - - if ((isset($sortKey) && $sortKey == $key) && (isset($sortDir) && $sortDir == "DESC")) { - echo '
      ' . $key . '
      '; - } elseif ((isset($sortKey) && $sortKey == $key) && (isset($sortDir) && $sortDir == "ASC")) { - echo '
      ' . $key . '
      '; - } else { - echo $key; - } - - $fieldList[] = $key; - - echo '
      '; - echo '
       
      '; - - } - - echo '
      '; - echo '
      '; - - $dataSql = $conn->query($q); - - $queryBuilder = ""; - - if (isset($primaryKeys) && count($primaryKeys) > 0) { - - echo '
      '; - - $m = 0; - - while (($dataRow = $conn->fetchAssoc($dataSql)) && ($m < $displayLimit)) { - - $queryBuilder = "WHERE "; - foreach ($primaryKeys as $primary) { - if ($conn->getAdapter() == "sqlite") { - $queryBuilder .= "" . $primary . "='" . $dataRow[$primary] . "' AND "; - } else { - $queryBuilder .= "`" . $primary . "`='" . $dataRow[$primary] . "' AND "; - } - } - $queryBuilder = substr($queryBuilder, 0, -5); - - if ($conn->getAdapter() == "mysql") { - $queryBuilder .= " LIMIT 1"; - } - - echo '
      '; - echo '
      '; - echo '
      '; - echo '
      '; - - $m++; - } - - echo '
      '; - - $dataSql = $conn->query($q); - - } - - if (isset($primaryKeys) && count($primaryKeys)) - echo '
      '; - else - echo '
      '; - - $m = 0; - - while (($dataRow = $conn->fetchArray($dataSql)) && ($m < $displayLimit)) { - - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      '; - - echo ''; - echo ''; - - for ($i=0; $i<$numFields; $i++) { - echo ''; - } - echo ''; - echo '
      '; - - if (isset($tableTypes) && in_array($tableTypes[$i], $binaryDTs)) { - echo '(' . __("binary data") . ')'; - } else if (is_numeric($dataRow[$i]) && stristr($fieldList[$i], "Date") !== false && strlen($dataRow[$i]) > 7 && strlen($dataRow[$i]) < 14) { - echo '' . formatForOutput($dataRow[$i]) . ''; - } else { - echo formatForOutput($dataRow[$i]); - } - - echo '
      '; - echo '
      '; - - $m++; - } - echo '
      '; - echo '
      '; - - ?> - - - - ' . sprintf(__("Your query affected %d rows."), $insertCount) . '
      '; - - if (isset($queryTable) && $queryTable) { - ?> - - - - ' . __("Your query did not return any results.") . " " . sprintf(__("(%.4f seconds)"), $queryTime) . '
      '; - } - } -} - -echo ''; - + + +*/ + +$totalRows = 0; +$insertCount = 0; +$queryTime = 0; + +$perPage = (isset($sbconfig) && array_key_exists("RowsPerPage", $sbconfig)) ? $sbconfig['RowsPerPage'] : 100; + +$displayLimit = 1000; + +$query = trim($query); + +if ($query) { + + if (!isset($queryTable)) { + $querySplit = splitQueryText($query); + } else { + $querySplit[] = $query; + } + + foreach ($querySplit as $q) { + $q = trim($q, "\n"); + if ($q != "") { + if (isset($queryTable)) { + $totalRows = $conn->tableRowCount($queryTable); + + if ($start > $totalRows) { + $start = 0; + } + + $q = "$q $sort LIMIT $start, $perPage"; + } + + $queryStartTime = microtime_float(); + $dataSql = $conn->query($q) or ($dbError[] = $conn->error()); + $queryFinishTime = microtime_float(); + $queryTime += round($queryFinishTime - $queryStartTime, 4); + + if ($conn->affectedRows($dataSql)) { + $insertCount += (int)($conn->affectedRows($dataSql)); + } + } + } + + if (!isset($queryTable)) { + $totalRows = (int)($conn->rowCount($dataSql)); + + // running rowCount on PDO resets the result set + // so we need to run the query again + if ($conn->getMethod() == "pdo") { + $dataSql = $conn->query($q); + } + } + +} + +//for the browse tab +if (isset($queryTable) && $conn->getAdapter() == "sqlite") { + $structure = $conn->describeTable($queryTable); + + if (sizeof($structure) > 0) { + foreach ($structure as $column) { + if (strpos($column[1], "primary key") > 0) { + $primaryKeys[] = $column[0]; + } + } + } +} else if (isset($queryTable) && $conn->getAdapter() == "mysql") { + $structureSql = $conn->describeTable($queryTable); + + if ($conn->isResultSet($structureSql)) { + while ($structureRow = $conn->fetchAssoc($structureSql)) { + $explosion = explode("(", $structureRow['Type'], 2); + + $tableTypes[] = $explosion[0]; + + if ($structureRow['Key'] == "PRI") { + $primaryKeys[] = $structureRow['Field']; + } + } + } +} + +echo '
      '; + +if (isset($dbError)) { + echo '
      ' . __("The following errors were reported") . ':'; + foreach ($dbError as $error) { + echo $error . "
      "; + } + echo '
      '; +} else { + + if (isset($totalRows) && $totalRows > 0) { + + if (isset($queryTable)) { + + echo ''; + echo ''; + echo ''; + + echo ''; + echo ''; + echo '
      '; + + if (isset($primaryKeys) && count($primaryKeys)) { + + echo __("Select") . ':  ' . __("All") . '  ' . __("None") . ''; + echo '     ' . __("With selected") . ':  ' . __("Edit") . '  ' . __("Delete") . ''; + + echo '       ' . __("Refresh") . ''; + + } else { + echo '[' . __("No primary key defined") . ']'; + } + + echo ''; + + $totalPages = ceil($totalRows / $perPage); + $currentPage = floor($start / $perPage) + 1; + + if ($currentPage > 1) { + echo '' . __("First") . ''; + echo '' . __("Prev") . ''; + } + + echo ''; + + if ($currentPage == 1) { + $startPage = 1; + $finishPage = 3; + + if ($finishPage > $totalPages) + $finishPage = $totalPages; + + } else if ($currentPage == $totalPages) { + $startPage = $totalPages - 2; + $finishPage = $totalPages; + + if ($startPage < 1) + $startPage = 1; + } else { + $startPage = $currentPage - 1; + $finishPage = $currentPage + 1; + } + + if ($startPage != $finishPage) { + for ($bnav=$startPage; $bnav<=$finishPage; $bnav++) { + echo '' . number_format($bnav) . ''; + } + } + + echo ''; + + if ($currentPage < $totalPages) { + echo '' . __("Next") . ''; + echo '' . __("Last") . ''; + } + + echo '
      '; + + } else { + echo ''; + echo ''; + echo ''; + echo ''; + echo '
      '; + + printf(__p("Your query returned %d result.", "Your query returned %d results.", $totalRows), $totalRows); + echo " " . sprintf(__("(%.4f seconds)"), $queryTime); + + if ($totalRows > $displayLimit) + echo ' (' . sprintf(__("Note: To avoid crashing your browser, only the first %d results have been displayed"), $displayLimit) . '.)'; + echo '
      '; + } + + echo '
      '; + + if (isset($primaryKeys) && count($primaryKeys)) { + echo '
       
      '; + } + + echo '
      '; + + echo '
      '; + echo ''; + echo ''; + + if ($conn->isResultSet($dataSql)) { + $dataRow = $conn->fetchAssoc($dataSql); + $g = 0; + $numFields = 0; + + foreach ($dataRow as $key=>$value) { + + if ((isset($sortKey) && $sortKey == $key) && (isset($sortDir) && $sortDir == "ASC")) { + $outputDir = "DESC"; + } elseif (isset($sortKey) && $sortKey == $key) { + $outputDir = "ASC"; + } elseif (isset($sortDir) && $sortDir) { + $outputDir = $sortDir; + } else { + $outputDir = "ASC"; + } + echo ''; + echo ''; + $numFields++; + } + echo ''; + echo ''; + echo '
      '; + + if ((isset($sortKey) && $sortKey == $key) && (isset($sortDir) && $sortDir == "DESC")) { + echo '
      ' . $key . '
      '; + } elseif ((isset($sortKey) && $sortKey == $key) && (isset($sortDir) && $sortDir == "ASC")) { + echo '
      ' . $key . '
      '; + } else { + echo $key; + } + + $fieldList[] = $key; + + echo '
      '; + echo '
       
      '; + + } + + echo '
      '; + echo '
      '; + + $dataSql = $conn->query($q); + + $queryBuilder = ""; + + if (isset($primaryKeys) && count($primaryKeys) > 0) { + + echo '
      '; + + $m = 0; + + while (($dataRow = $conn->fetchAssoc($dataSql)) && ($m < $displayLimit)) { + + $queryBuilder = "WHERE "; + foreach ($primaryKeys as $primary) { + if ($conn->getAdapter() == "sqlite") { + $queryBuilder .= "" . $primary . "='" . $dataRow[$primary] . "' AND "; + } else { + $queryBuilder .= "`" . $primary . "`='" . $dataRow[$primary] . "' AND "; + } + } + $queryBuilder = substr($queryBuilder, 0, -5); + + if ($conn->getAdapter() == "mysql") { + $queryBuilder .= " LIMIT 1"; + } + + echo '
      '; + echo '
      '; + echo '
      '; + echo '
      '; + + $m++; + } + + echo '
      '; + + $dataSql = $conn->query($q); + + } + + if (isset($primaryKeys) && count($primaryKeys)) + echo '
      '; + else + echo '
      '; + + $m = 0; + + while (($dataRow = $conn->fetchArray($dataSql)) && ($m < $displayLimit)) { + + echo ''; + echo ''; + echo ''; + echo ''; + echo '
      '; + + echo ''; + echo ''; + + for ($i=0; $i<$numFields; $i++) { + echo ''; + } + echo ''; + echo '
      '; + + if (isset($tableTypes) && in_array($tableTypes[$i], $binaryDTs)) { + echo '(' . __("binary data") . ')'; + } else if (is_numeric($dataRow[$i]) && stristr($fieldList[$i], "Date") !== false && strlen($dataRow[$i]) > 7 && strlen($dataRow[$i]) < 14) { + echo '' . formatForOutput($dataRow[$i]) . ''; + } else { + echo formatForOutput($dataRow[$i]); + } + + echo '
      '; + echo '
      '; + + $m++; + } + echo '
      '; + echo '
      '; + + ?> + + + + ' . sprintf(__("Your query affected %d rows."), $insertCount) . '
      '; + + if (isset($queryTable) && $queryTable) { + ?> + + + + ' . __("Your query did not return any results.") . " " . sprintf(__("(%.4f seconds)"), $queryTime) . '
      '; + } + } +} + +echo ''; + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/includes/class/GetTextReader.php b/htdocs/sqlbuddy/includes/class/GetTextReader.php index b63dc7c4e..af8e1e481 100755 --- a/htdocs/sqlbuddy/includes/class/GetTextReader.php +++ b/htdocs/sqlbuddy/includes/class/GetTextReader.php @@ -1,78 +1,78 @@ - - -*/ - -class GetTextReader { - - var $translationIndex = array(); - var $basePath = "locale/"; - - function GetTextReader($inputFile) { - - $msgId = ""; - $msgIdPlural = ""; - $msgStr = ""; - $msgStrPlural = ""; - - $readFile = $this->basePath . $inputFile; - - if (file_exists($readFile)) { - $handle = fopen($readFile, "r"); - if ($handle) { - while (!feof($handle)) - { - $lines[] = trim(fgets($handle, 4096)); - } - fclose($handle); - } - - foreach ($lines as $line) { - if (substr($line, 0, 6) == "msgid:") { - $msgId = substr($line, 8, -1); - $msgStr = ""; - } else if (substr($line, 0, 13) == "msgid_plural:") { - $msgIdPlural = substr($line, 15, -1); - } else if (substr($line, 0, 7) == "msgstr:") { - $msgStr = substr($line, 9, -1); - } else if (substr($line, 0, 10) == "msgstr[0]:") { - $msgStr = substr($line, 12, -1); - } else if (substr($line, 0, 10) == "msgstr[1]:") { - $msgStrPlural = substr($line, 12, -1); - } - - if ($msgId && $msgStr) { - $this->translationIndex[$msgId] = $msgStr; - if ($msgIdPlural) - $this->translationIndex[$msgIdPlural] = $msgStrPlural; - - $msgId = ""; - $msgIdPlural = ""; - $msgStr = ""; - $msgStrPlural = ""; - } - } - } - } - - function getTranslation($lookup) { - if (array_key_exists($lookup, $this->translationIndex)) { - return $this->translationIndex[$lookup]; - } else { - return $lookup; - } - } - -} - + + +*/ + +class GetTextReader { + + var $translationIndex = array(); + var $basePath = "locale/"; + + function __construct($inputFile) { + + $msgId = ""; + $msgIdPlural = ""; + $msgStr = ""; + $msgStrPlural = ""; + + $readFile = $this->basePath . $inputFile; + + if (file_exists($readFile)) { + $handle = fopen($readFile, "r"); + if ($handle) { + while (!feof($handle)) + { + $lines[] = trim(fgets($handle, 4096)); + } + fclose($handle); + } + + foreach ($lines as $line) { + if (substr($line, 0, 6) == "msgid:") { + $msgId = substr($line, 8, -1); + $msgStr = ""; + } else if (substr($line, 0, 13) == "msgid_plural:") { + $msgIdPlural = substr($line, 15, -1); + } else if (substr($line, 0, 7) == "msgstr:") { + $msgStr = substr($line, 9, -1); + } else if (substr($line, 0, 10) == "msgstr[0]:") { + $msgStr = substr($line, 12, -1); + } else if (substr($line, 0, 10) == "msgstr[1]:") { + $msgStrPlural = substr($line, 12, -1); + } + + if ($msgId && $msgStr) { + $this->translationIndex[$msgId] = $msgStr; + if ($msgIdPlural) + $this->translationIndex[$msgIdPlural] = $msgStrPlural; + + $msgId = ""; + $msgIdPlural = ""; + $msgStr = ""; + $msgStrPlural = ""; + } + } + } + } + + function getTranslation($lookup) { + if (array_key_exists($lookup, $this->translationIndex)) { + return $this->translationIndex[$lookup]; + } else { + return $lookup; + } + } + +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/includes/class/Sql-php4.php b/htdocs/sqlbuddy/includes/class/Sql-php4.php index 59cf14eb1..17a7eba9f 100755 --- a/htdocs/sqlbuddy/includes/class/Sql-php4.php +++ b/htdocs/sqlbuddy/includes/class/Sql-php4.php @@ -1,424 +1,424 @@ - - -*/ - -class SQL { - - var $adapter = ""; - var $method = ""; - var $version = ""; - var $conn = ""; - var $options = ""; - var $errorMessage = ""; - var $db = ""; - - function SQL($connString, $user = "", $pass = "") { - list($this->adapter, $options) = explode(":", $connString, 2); - - if ($this->adapter != "sqlite") { - $this->adapter = "mysql"; - } - - $optionsList = explode(";", $options); - - foreach ($optionsList as $option) { - list($a, $b) = explode("=", $option); - $opt[$a] = $b; - } - - $this->options = $opt; - $database = (array_key_exists("database", $opt)) ? $opt['database'] : ""; - - if ($this->adapter == "sqlite") { - $this->method = "sqlite"; - $this->conn = sqlite_open($database, 0666, $sqliteError); - } else { - $this->method = "mysql"; - $host = (array_key_exists("host", $opt)) ? $opt['host'] : ""; - $this->conn = @mysql_connect($host, $user, $pass); - } - - if ($this->conn && $this->adapter == "mysql") { - $this->query("SET NAMES 'utf8'"); - } - } - - function isConnected() { - return ($this->conn !== false); - } - - function disconnect() { - if ($this->conn) { - if ($this->method == "mysql") { - mysql_close($this->conn); - $this->conn = null; - } else if ($this->method == "sqlite") { - sqlite_close($this->conn); - $this->conn = null; - } - } - } - - function getAdapter() { - return $this->adapter; - } - - function getMethod() { - return $this->method; - } - - function getOptionValue($optKey) { - if (array_key_exists($optKey, $this->options)) { - return $this->options[$optKey]; - } else { - return false; - } - } - - function selectDB($db) { - if ($this->conn) { - - $this->db = $db; - - if ($this->method == "mysql") { - return (mysql_select_db($db)); - } else { - return true; - } - } else { - return false; - } - } - - function query($queryText) { - if ($this->conn) { - if ($this->method == "mysql") { - $queryResult = @mysql_query($queryText, $this->conn); - - if (!$queryResult) { - $this->errorMessage = mysql_error(); - } - - return $queryResult; - } else if ($this->method == "sqlite") { - $queryResult = sqlite_query($this->conn, $queryText); - - if (!$queryResult) { - $this->errorMessage = sqlite_error_string(sqlite_last_error($this->conn)); - } - - return $queryResult; - } - } else { - return false; - } - } - - function rowCount($resultSet) { - if ($this->conn) { - if ($this->method == "mysql") { - return @mysql_num_rows($resultSet); - } else if ($this->method == "sqlite") { - return @sqlite_num_rows($resultSet); - } - } - } - - function isResultSet($resultSet) { - if ($this->conn) { - return ($this->rowCount($resultSet) > 0); - } - } - - function fetchArray($resultSet) { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "mysql") { - return mysql_fetch_row($resultSet); - } else if ($this->method == "sqlite") { - return sqlite_fetch_array($resultSet, SQLITE_NUM); - } - } - } - - function fetchAssoc($resultSet) { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "mysql") { - return mysql_fetch_assoc($resultSet); - } else if ($this->method == "sqlite") { - return sqlite_fetch_array($resultSet, SQLITE_ASSOC); - } - } - } - - function affectedRows($resultSet) { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "mysql") { - return @mysql_affected_rows($resultSet); - } else if ($this->method == "sqlite") { - return sqlite_changes($resultSet); - } - } - } - - function result($resultSet, $targetRow, $targetColumn = "") { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "mysql") { - return mysql_result($resultSet, $targetRow, $targetColumn); - } else if ($this->method == "sqlite") { - return sqlite_column($resultSet, $targetColumn); - } - } - } - - function listDatabases() { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("SHOW DATABASES"); - } else if ($this->adapter == "sqlite") { - $database = (array_key_exists("database", $this->options)) ? $this->options['database'] : ""; - return $database; - } - } - } - - function listTables() { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("SHOW TABLES"); - } else if ($this->adapter == "sqlite") { - return $this->query("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name"); - } - } - } - - function hasCharsetSupport() - { - if ($this->conn) { - if ($this->adapter == "mysql" && version_compare($this->getVersion(), "4.1", ">")) { - return true; - } else { - return false; - } - } - } - - function listCharset() { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("SHOW CHARACTER SET"); - } else if ($this->adapter == "sqlite") { - return ""; - } - } - } - - function listCollation() { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("SHOW COLLATION"); - } else if ($this->adapter == "sqlite") { - return ""; - } - } - } - - function insertId($resultSet = null) { - if ($this->conn) { - if ($this->method == "mysql") { - return mysql_insert_id($resultSet); - } else if ($this->method == "sqlite") { - return sqlite_last_insert_rowid($resultSet); - } - } - } - - function escapeString($toEscape) { - if ($this->conn) { - if ($this->adapter == "mysql") { - return mysql_real_escape_string($toEscape); - } else if ($this->adapter == "sqlite") { - return sqlite_escape_string($toEscape); - } - } - } - - function getVersion() { - if ($this->conn) { - // cache - if ($this->version) { - return $this->version; - } - - if ($this->adapter == "mysql") { - $verSql = mysql_get_server_info(); - $version = explode("-", $verSql); - $this->version = $version[0]; - return $this->version; - } else if ($this->adapter == "sqlite") { - $this->version = sqlite_libversion(); - return $this->version; - } - } - - } - - // returns the number of rows in a table - function tableRowCount($table) { - if ($this->conn) { - if ($this->adapter == "mysql") { - $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table . "`"); - $count = (int)($this->result($countSql, 0, "RowCount")); - return $count; - } else if ($this->adapter == "sqlite") { - $countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $table . "'"); - $count = (int)($this->result($countSql, 0, "RowCount")); - return $count; - } - } - } - - // gets column info for a table - function describeTable($table) { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("DESCRIBE `" . $table . "`"); - } else if ($this->adapter == "sqlite") { - $columnSql = $this->query("SELECT sql FROM sqlite_master where tbl_name = '" . $table . "'"); - $columnInfo = $this->result($columnSql, 0, "sql"); - $columnStart = strpos($columnInfo, '('); - $columns = substr($columnInfo, $columnStart+1, -1); - $columns = split(',[^0-9]', $columns); - - $columnList = array(); - - foreach ($columns as $column) { - $column = trim($column); - $columnSplit = explode(" ", $column, 2); - $columnName = $columnSplit[0]; - $columnType = (sizeof($columnSplit) > 1) ? $columnSplit[1] : ""; - $columnList[] = array($columnName, $columnType); - } - - return $columnList; - } - } - } - - /* - Return names, row counts etc for every database, table and view in a JSON string - */ - function getMetadata() { - $output = ''; - if ($this->conn) { - if ($this->adapter == "mysql" && version_compare($this->getVersion(), "5.0.0", ">=")) { - $this->selectDB("information_schema"); - $schemaSql = $this->query("SELECT `SCHEMA_NAME` FROM `SCHEMATA` ORDER BY `SCHEMA_NAME`"); - if ($this->rowCount($schemaSql)) { - while ($schema = $this->fetchAssoc($schemaSql)) { - $output .= '{"name": "' . $schema['SCHEMA_NAME'] . '"'; - // other interesting columns: TABLE_TYPE, ENGINE, TABLE_COLUMN and many more - $tableSql = $this->query("SELECT `TABLE_NAME`, `TABLE_ROWS` FROM `TABLES` WHERE `TABLE_SCHEMA`='" . $schema['SCHEMA_NAME'] . "' ORDER BY `TABLE_NAME`"); - if ($this->rowCount($tableSql)) { - $output .= ',"items": ['; - while ($table = $this->fetchAssoc($tableSql)) { - - if ($schema['SCHEMA_NAME'] == "information_schema") { - $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table['TABLE_NAME'] . "`"); - $rowCount = (int)($this->result($countSql, 0, "RowCount")); - } else { - $rowCount = (int)($table['TABLE_ROWS']); - } - - $output .= '{"name":"' . $table['TABLE_NAME'] . '","rowcount":' . $rowCount . '},'; - } - - if (substr($output, -1) == ",") - $output = substr($output, 0, -1); - - $output .= ']'; - } - $output .= '},'; - } - $output = substr($output, 0, -1); - } - } else if ($this->adapter == "mysql") { - $schemaSql = $this->listDatabases(); - - if ($this->rowCount($schemaSql)) { - while ($schema = $this->fetchArray($schemaSql)) { - $output .= '{"name": "' . $schema[0] . '"'; - - $this->selectDB($schema[0]); - $tableSql = $this->listTables(); - - if ($this->rowCount($tableSql)) { - $output .= ',"items": ['; - while ($table = $this->fetchArray($tableSql)) { - $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table[0] . "`"); - $rowCount = (int)($this->result($countSql, 0, "RowCount")); - $output .= '{"name":"' . $table[0] . '","rowcount":' . $rowCount . '},'; - } - - if (substr($output, -1) == ",") - $output = substr($output, 0, -1); - - $output .= ']'; - } - $output .= '},'; - } - $output = substr($output, 0, -1); - } - } else if ($this->adapter == "sqlite") { - $database = (array_key_exists("database", $this->options)) ? $this->options['database'] : ""; - - $output .= '{"name": "' . $database . '"'; - - $tableSql = $this->listTables(); - - if ($this->rowCount($tableSql)) { - $output .= ',"items": ['; - while ($tableRow = $this->fetchArray($tableSql)) { - $countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $tableRow[0] . "'"); - $rowCount = (int)($this->result($countSql, 0, "RowCount")); - $output .= '{"name":"' . $tableRow[0] . '","rowcount":' . $rowCount . '},'; - } - - if (substr($output, -1) == ",") - $output = substr($output, 0, -1); - - $output .= ']'; - } - $output .= '}'; - } - } - return $output; - } - - function error() { - return $this->errorMessage; - } - + + +*/ + +class SQL { + + var $adapter = ""; + var $method = ""; + var $version = ""; + var $conn = ""; + var $options = ""; + var $errorMessage = ""; + var $db = ""; + + function SQL($connString, $user = "", $pass = "") { + list($this->adapter, $options) = explode(":", $connString, 2); + + if ($this->adapter != "sqlite") { + $this->adapter = "mysql"; + } + + $optionsList = explode(";", $options); + + foreach ($optionsList as $option) { + list($a, $b) = explode("=", $option); + $opt[$a] = $b; + } + + $this->options = $opt; + $database = (array_key_exists("database", $opt)) ? $opt['database'] : ""; + + if ($this->adapter == "sqlite") { + $this->method = "sqlite"; + $this->conn = sqlite_open($database, 0666, $sqliteError); + } else { + $this->method = "mysql"; + $host = (array_key_exists("host", $opt)) ? $opt['host'] : ""; + $this->conn = @mysql_connect($host, $user, $pass); + } + + if ($this->conn && $this->adapter == "mysql") { + $this->query("SET NAMES 'utf8'"); + } + } + + function isConnected() { + return ($this->conn !== false); + } + + function disconnect() { + if ($this->conn) { + if ($this->method == "mysql") { + mysql_close($this->conn); + $this->conn = null; + } else if ($this->method == "sqlite") { + sqlite_close($this->conn); + $this->conn = null; + } + } + } + + function getAdapter() { + return $this->adapter; + } + + function getMethod() { + return $this->method; + } + + function getOptionValue($optKey) { + if (array_key_exists($optKey, $this->options)) { + return $this->options[$optKey]; + } else { + return false; + } + } + + function selectDB($db) { + if ($this->conn) { + + $this->db = $db; + + if ($this->method == "mysql") { + return (mysql_select_db($db)); + } else { + return true; + } + } else { + return false; + } + } + + function query($queryText) { + if ($this->conn) { + if ($this->method == "mysql") { + $queryResult = @mysql_query($queryText, $this->conn); + + if (!$queryResult) { + $this->errorMessage = mysql_error(); + } + + return $queryResult; + } else if ($this->method == "sqlite") { + $queryResult = sqlite_query($this->conn, $queryText); + + if (!$queryResult) { + $this->errorMessage = sqlite_error_string(sqlite_last_error($this->conn)); + } + + return $queryResult; + } + } else { + return false; + } + } + + function rowCount($resultSet) { + if ($this->conn) { + if ($this->method == "mysql") { + return @mysql_num_rows($resultSet); + } else if ($this->method == "sqlite") { + return @sqlite_num_rows($resultSet); + } + } + } + + function isResultSet($resultSet) { + if ($this->conn) { + return ($this->rowCount($resultSet) > 0); + } + } + + function fetchArray($resultSet) { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "mysql") { + return mysql_fetch_row($resultSet); + } else if ($this->method == "sqlite") { + return sqlite_fetch_array($resultSet, SQLITE_NUM); + } + } + } + + function fetchAssoc($resultSet) { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "mysql") { + return mysql_fetch_assoc($resultSet); + } else if ($this->method == "sqlite") { + return sqlite_fetch_array($resultSet, SQLITE_ASSOC); + } + } + } + + function affectedRows($resultSet) { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "mysql") { + return @mysql_affected_rows($resultSet); + } else if ($this->method == "sqlite") { + return sqlite_changes($resultSet); + } + } + } + + function result($resultSet, $targetRow, $targetColumn = "") { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "mysql") { + return mysql_result($resultSet, $targetRow, $targetColumn); + } else if ($this->method == "sqlite") { + return sqlite_column($resultSet, $targetColumn); + } + } + } + + function listDatabases() { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("SHOW DATABASES"); + } else if ($this->adapter == "sqlite") { + $database = (array_key_exists("database", $this->options)) ? $this->options['database'] : ""; + return $database; + } + } + } + + function listTables() { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("SHOW TABLES"); + } else if ($this->adapter == "sqlite") { + return $this->query("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name"); + } + } + } + + function hasCharsetSupport() + { + if ($this->conn) { + if ($this->adapter == "mysql" && version_compare($this->getVersion(), "4.1", ">")) { + return true; + } else { + return false; + } + } + } + + function listCharset() { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("SHOW CHARACTER SET"); + } else if ($this->adapter == "sqlite") { + return ""; + } + } + } + + function listCollation() { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("SHOW COLLATION"); + } else if ($this->adapter == "sqlite") { + return ""; + } + } + } + + function insertId($resultSet = null) { + if ($this->conn) { + if ($this->method == "mysql") { + return mysql_insert_id($resultSet); + } else if ($this->method == "sqlite") { + return sqlite_last_insert_rowid($resultSet); + } + } + } + + function escapeString($toEscape) { + if ($this->conn) { + if ($this->adapter == "mysql") { + return mysql_real_escape_string($toEscape); + } else if ($this->adapter == "sqlite") { + return sqlite_escape_string($toEscape); + } + } + } + + function getVersion() { + if ($this->conn) { + // cache + if ($this->version) { + return $this->version; + } + + if ($this->adapter == "mysql") { + $verSql = mysql_get_server_info(); + $version = explode("-", $verSql); + $this->version = $version[0]; + return $this->version; + } else if ($this->adapter == "sqlite") { + $this->version = sqlite_libversion(); + return $this->version; + } + } + + } + + // returns the number of rows in a table + function tableRowCount($table) { + if ($this->conn) { + if ($this->adapter == "mysql") { + $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table . "`"); + $count = (int)($this->result($countSql, 0, "RowCount")); + return $count; + } else if ($this->adapter == "sqlite") { + $countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $table . "'"); + $count = (int)($this->result($countSql, 0, "RowCount")); + return $count; + } + } + } + + // gets column info for a table + function describeTable($table) { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("DESCRIBE `" . $table . "`"); + } else if ($this->adapter == "sqlite") { + $columnSql = $this->query("SELECT sql FROM sqlite_master where tbl_name = '" . $table . "'"); + $columnInfo = $this->result($columnSql, 0, "sql"); + $columnStart = strpos($columnInfo, '('); + $columns = substr($columnInfo, $columnStart+1, -1); + $columns = split(',[^0-9]', $columns); + + $columnList = array(); + + foreach ($columns as $column) { + $column = trim($column); + $columnSplit = explode(" ", $column, 2); + $columnName = $columnSplit[0]; + $columnType = (sizeof($columnSplit) > 1) ? $columnSplit[1] : ""; + $columnList[] = array($columnName, $columnType); + } + + return $columnList; + } + } + } + + /* + Return names, row counts etc for every database, table and view in a JSON string + */ + function getMetadata() { + $output = ''; + if ($this->conn) { + if ($this->adapter == "mysql" && version_compare($this->getVersion(), "5.0.0", ">=")) { + $this->selectDB("information_schema"); + $schemaSql = $this->query("SELECT `SCHEMA_NAME` FROM `SCHEMATA` ORDER BY `SCHEMA_NAME`"); + if ($this->rowCount($schemaSql)) { + while ($schema = $this->fetchAssoc($schemaSql)) { + $output .= '{"name": "' . $schema['SCHEMA_NAME'] . '"'; + // other interesting columns: TABLE_TYPE, ENGINE, TABLE_COLUMN and many more + $tableSql = $this->query("SELECT `TABLE_NAME`, `TABLE_ROWS` FROM `TABLES` WHERE `TABLE_SCHEMA`='" . $schema['SCHEMA_NAME'] . "' ORDER BY `TABLE_NAME`"); + if ($this->rowCount($tableSql)) { + $output .= ',"items": ['; + while ($table = $this->fetchAssoc($tableSql)) { + + if ($schema['SCHEMA_NAME'] == "information_schema") { + $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table['TABLE_NAME'] . "`"); + $rowCount = (int)($this->result($countSql, 0, "RowCount")); + } else { + $rowCount = (int)($table['TABLE_ROWS']); + } + + $output .= '{"name":"' . $table['TABLE_NAME'] . '","rowcount":' . $rowCount . '},'; + } + + if (substr($output, -1) == ",") + $output = substr($output, 0, -1); + + $output .= ']'; + } + $output .= '},'; + } + $output = substr($output, 0, -1); + } + } else if ($this->adapter == "mysql") { + $schemaSql = $this->listDatabases(); + + if ($this->rowCount($schemaSql)) { + while ($schema = $this->fetchArray($schemaSql)) { + $output .= '{"name": "' . $schema[0] . '"'; + + $this->selectDB($schema[0]); + $tableSql = $this->listTables(); + + if ($this->rowCount($tableSql)) { + $output .= ',"items": ['; + while ($table = $this->fetchArray($tableSql)) { + $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table[0] . "`"); + $rowCount = (int)($this->result($countSql, 0, "RowCount")); + $output .= '{"name":"' . $table[0] . '","rowcount":' . $rowCount . '},'; + } + + if (substr($output, -1) == ",") + $output = substr($output, 0, -1); + + $output .= ']'; + } + $output .= '},'; + } + $output = substr($output, 0, -1); + } + } else if ($this->adapter == "sqlite") { + $database = (array_key_exists("database", $this->options)) ? $this->options['database'] : ""; + + $output .= '{"name": "' . $database . '"'; + + $tableSql = $this->listTables(); + + if ($this->rowCount($tableSql)) { + $output .= ',"items": ['; + while ($tableRow = $this->fetchArray($tableSql)) { + $countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $tableRow[0] . "'"); + $rowCount = (int)($this->result($countSql, 0, "RowCount")); + $output .= '{"name":"' . $tableRow[0] . '","rowcount":' . $rowCount . '},'; + } + + if (substr($output, -1) == ",") + $output = substr($output, 0, -1); + + $output .= ']'; + } + $output .= '}'; + } + } + return $output; + } + + function error() { + return $this->errorMessage; + } + } \ No newline at end of file diff --git a/htdocs/sqlbuddy/includes/class/Sql.php b/htdocs/sqlbuddy/includes/class/Sql.php index f42980c27..f907d6d82 100755 --- a/htdocs/sqlbuddy/includes/class/Sql.php +++ b/htdocs/sqlbuddy/includes/class/Sql.php @@ -1,495 +1,503 @@ - - -*/ - -class SQL { - - var $adapter = ""; - var $method = ""; - var $version = ""; - var $conn = ""; - var $options = ""; - var $errorMessage = ""; - var $db = ""; - - function SQL($connString, $user = "", $pass = "") { - list($this->adapter, $options) = explode(":", $connString, 2); - - if ($this->adapter != "sqlite") { - $this->adapter = "mysql"; - } - - $optionsList = explode(";", $options); - - foreach ($optionsList as $option) { - list($a, $b) = explode("=", $option); - $opt[$a] = $b; - } - - $this->options = $opt; - $database = (array_key_exists("database", $opt)) ? $opt['database'] : ""; - - if ($this->adapter == "sqlite" && substr(sqlite_libversion(), 0, 1) == "3" && class_exists("PDO") && in_array("sqlite", PDO::getAvailableDrivers())) { - $this->method = "pdo"; - - try - { - $this->conn = new PDO("sqlite:" . $database, null, null, array(PDO::ATTR_PERSISTENT => true)); - } - catch (PDOException $error) { - $this->conn = false; - $this->errorMessage = $error->getMessage(); - } - } else if ($this->adapter == "sqlite" && substr(sqlite_libversion(), 0, 1) == "2" && class_exists("PDO") && in_array("sqlite2", PDO::getAvailableDrivers())) { - $this->method = "pdo"; - - try - { - $this->conn = new PDO("sqlite2:" . $database, null, null, array(PDO::ATTR_PERSISTENT => true)); - } - catch (PDOException $error) { - $this->conn = false; - $this->errorMessage = $error->getMessage(); - } - } else if ($this->adapter == "sqlite") { - $this->method = "sqlite"; - $this->conn = sqlite_open($database, 0666, $sqliteError); - } else { - $this->method = "mysql"; - $host = (array_key_exists("host", $opt)) ? $opt['host'] : ""; - $this->conn = @mysql_connect($host, $user, $pass); - } - - if ($this->conn && $this->method == "pdo") { - $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); - } - - if ($this->conn && $this->adapter == "mysql") { - $this->query("SET NAMES 'utf8'"); - } - - if ($this->conn && $database) { - $this->db = $database; - } - } - - function isConnected() { - return ($this->conn !== false); - } - - function disconnect() { - if ($this->conn) { - if ($this->method == "pdo") { - $this->conn = null; - } else if ($this->method == "mysql") { - mysql_close($this->conn); - $this->conn = null; - } else if ($this->method == "sqlite") { - sqlite_close($this->conn); - $this->conn = null; - } - } - } - - function getAdapter() { - return $this->adapter; - } - - function getMethod() { - return $this->method; - } - - function getOptionValue($optKey) { - if (array_key_exists($optKey, $this->options)) { - return $this->options[$optKey]; - } else { - return false; - } - } - - function selectDB($db) { - if ($this->conn) { - if ($this->method == "mysql") { - $this->db = $db; - return (mysql_select_db($db)); - } else { - return true; - } - } else { - return false; - } - } - - function query($queryText) { - if ($this->conn) { - if ($this->method == "pdo") { - $queryResult = $this->conn->prepare($queryText); - - if ($queryResult) - $queryResult->execute(); - - if (!$queryResult) { - $errorInfo = $this->conn->errorInfo(); - $this->errorMessage = $errorInfo[2]; - } - - return $queryResult; - } else if ($this->method == "mysql") { - $queryResult = @mysql_query($queryText, $this->conn); - - if (!$queryResult) { - $this->errorMessage = mysql_error(); - } - - return $queryResult; - } else if ($this->method == "sqlite") { - $queryResult = sqlite_query($this->conn, $queryText); - - if (!$queryResult) { - $this->errorMessage = sqlite_error_string(sqlite_last_error($this->conn)); - } - - return $queryResult; - } - } else { - return false; - } - } - - // Be careful using this function - when used with pdo, the pointer is moved - // to the end of the result set and the query needs to be rerun. Unless you - // actually need a count of the rows, use the isResultSet() function instead - function rowCount($resultSet) { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "pdo") { - return count($resultSet->fetchAll()); - } else if ($this->method == "mysql") { - return @mysql_num_rows($resultSet); - } else if ($this->method == "sqlite") { - return @sqlite_num_rows($resultSet); - } - } - } - - function isResultSet($resultSet) { - if ($this->conn) { - if ($this->method == "pdo") { - return ($resultSet == true); - } else { - return ($this->rowCount($resultSet) > 0); - } - } - } - - function fetchArray($resultSet) { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "pdo") { - return $resultSet->fetch(PDO::FETCH_NUM); - } else if ($this->method == "mysql") { - return mysql_fetch_row($resultSet); - } else if ($this->method == "sqlite") { - return sqlite_fetch_array($resultSet, SQLITE_NUM); - } - } - } - - function fetchAssoc($resultSet) { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "pdo") { - return $resultSet->fetch(PDO::FETCH_ASSOC); - } else if ($this->method == "mysql") { - return mysql_fetch_assoc($resultSet); - } else if ($this->method == "sqlite") { - return sqlite_fetch_array($resultSet, SQLITE_ASSOC); - } - } - } - - function affectedRows($resultSet) { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "pdo") { - return $resultSet->rowCount(); - } else if ($this->method == "mysql") { - return @mysql_affected_rows($resultSet); - } else if ($this->method == "sqlite") { - return sqlite_changes($resultSet); - } - } - } - - function result($resultSet, $targetRow, $targetColumn = "") { - if (!$resultSet) - return false; - - if ($this->conn) { - if ($this->method == "pdo") { - if ($targetColumn) { - $resultRow = $resultSet->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, $targetRow); - return $resultRow[$targetColumn]; - } else { - $resultRow = $resultSet->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_ABS, $targetRow); - return $resultRow[0]; - } - } else if ($this->method == "mysql") { - return mysql_result($resultSet, $targetRow, $targetColumn); - } else if ($this->method == "sqlite") { - return sqlite_column($resultSet, $targetColumn); - } - } - } - - function listDatabases() { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("SHOW DATABASES"); - } else if ($this->adapter == "sqlite") { - return $this->db; - } - } - } - - function listTables() { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("SHOW TABLES"); - } else if ($this->adapter == "sqlite") { - return $this->query("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name"); - } - } - } - - function hasCharsetSupport() - { - if ($this->conn) { - if ($this->adapter == "mysql" && version_compare($this->getVersion(), "4.1", ">")) { - return true; - } else { - return false; - } - } - } - - function listCharset() { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("SHOW CHARACTER SET"); - } else if ($this->adapter == "sqlite") { - return ""; - } - } - } - - function listCollation() { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("SHOW COLLATION"); - } else if ($this->adapter == "sqlite") { - return ""; - } - } - } - - function insertId() { - if ($this->conn) { - if ($this->method == "pdo") { - return $this->conn->lastInsertId(); - } else if ($this->method == "mysql") { - return @mysql_insert_id($this->conn); - } else if ($this->method == "sqlite") { - return sqlite_last_insert_rowid($this-conn); - } - } - } - - function escapeString($toEscape) { - if ($this->conn) { - if ($this->method == "pdo") { - $toEscape = $this->conn->quote($toEscape); - $toEscape = substr($toEscape, 1, -1); - return $toEscape; - } else if ($this->adapter == "mysql") { - return mysql_real_escape_string($toEscape); - } else if ($this->adapter == "sqlite") { - return sqlite_escape_string($toEscape); - } - } - } - - function getVersion() { - if ($this->conn) { - // cache - if ($this->version) { - return $this->version; - } - - if ($this->adapter == "mysql") { - $verSql = mysql_get_server_info(); - $version = explode("-", $verSql); - $this->version = $version[0]; - return $this->version; - } else if ($this->adapter == "sqlite") { - $this->version = sqlite_libversion(); - return $this->version; - } - } - - } - - // returns the number of rows in a table - function tableRowCount($table) { - if ($this->conn) { - if ($this->adapter == "mysql") { - $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table . "`"); - $count = (int)($this->result($countSql, 0, "RowCount")); - return $count; - } else if ($this->adapter == "sqlite") { - $countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $table . "'"); - $count = (int)($this->result($countSql, 0, "RowCount")); - return $count; - } - } - } - - // gets column info for a table - function describeTable($table) { - if ($this->conn) { - if ($this->adapter == "mysql") { - return $this->query("DESCRIBE `" . $table . "`"); - } else if ($this->adapter == "sqlite") { - $columnSql = $this->query("SELECT sql FROM sqlite_master where tbl_name = '" . $table . "'"); - $columnInfo = $this->result($columnSql, 0, "sql"); - $columnStart = strpos($columnInfo, '('); - $columns = substr($columnInfo, $columnStart+1, -1); - $columns = split(',[^0-9]', $columns); - - $columnList = array(); - - foreach ($columns as $column) { - $column = trim($column); - $columnSplit = explode(" ", $column, 2); - $columnName = $columnSplit[0]; - $columnType = (sizeof($columnSplit) > 1) ? $columnSplit[1] : ""; - $columnList[] = array($columnName, $columnType); - } - - return $columnList; - } - } - } - - /* - Return names, row counts etc for every database, table and view in a JSON string - */ - function getMetadata() { - $output = ''; - if ($this->conn) { - if ($this->adapter == "mysql" && version_compare($this->getVersion(), "5.0.0", ">=")) { - $this->selectDB("information_schema"); - $schemaSql = $this->query("SELECT `SCHEMA_NAME` FROM `SCHEMATA` ORDER BY `SCHEMA_NAME`"); - if ($this->rowCount($schemaSql)) { - while ($schema = $this->fetchAssoc($schemaSql)) { - $output .= '{"name": "' . $schema['SCHEMA_NAME'] . '"'; - // other interesting columns: TABLE_TYPE, ENGINE, TABLE_COLUMN and many more - $tableSql = $this->query("SELECT `TABLE_NAME`, `TABLE_ROWS` FROM `TABLES` WHERE `TABLE_SCHEMA`='" . $schema['SCHEMA_NAME'] . "' ORDER BY `TABLE_NAME`"); - if ($this->rowCount($tableSql)) { - $output .= ',"items": ['; - while ($table = $this->fetchAssoc($tableSql)) { - - if ($schema['SCHEMA_NAME'] == "information_schema") { - $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table['TABLE_NAME'] . "`"); - $rowCount = (int)($this->result($countSql, 0, "RowCount")); - } else { - $rowCount = (int)($table['TABLE_ROWS']); - } - - $output .= '{"name":"' . $table['TABLE_NAME'] . '","rowcount":' . $rowCount . '},'; - } - - if (substr($output, -1) == ",") - $output = substr($output, 0, -1); - - $output .= ']'; - } - $output .= '},'; - } - $output = substr($output, 0, -1); - } - } else if ($this->adapter == "mysql") { - $schemaSql = $this->listDatabases(); - - if ($this->rowCount($schemaSql)) { - while ($schema = $this->fetchArray($schemaSql)) { - $output .= '{"name": "' . $schema[0] . '"'; - - $this->selectDB($schema[0]); - $tableSql = $this->listTables(); - - if ($this->rowCount($tableSql)) { - $output .= ',"items": ['; - while ($table = $this->fetchArray($tableSql)) { - $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table[0] . "`"); - $rowCount = (int)($this->result($countSql, 0, "RowCount")); - $output .= '{"name":"' . $table[0] . '","rowcount":' . $rowCount . '},'; - } - - if (substr($output, -1) == ",") - $output = substr($output, 0, -1); - - $output .= ']'; - } - $output .= '},'; - } - $output = substr($output, 0, -1); - } - } else if ($this->adapter == "sqlite") { - $output .= '{"name": "' . $this->db . '"'; - - $tableSql = $this->listTables(); - - if ($tableSql) { - $output .= ',"items": ['; - while ($tableRow = $this->fetchArray($tableSql)) { - $countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $tableRow[0] . "'"); - $rowCount = (int)($this->result($countSql, 0, "RowCount")); - $output .= '{"name":"' . $tableRow[0] . '","rowcount":' . $rowCount . '},'; - } - - if (substr($output, -1) == ",") - $output = substr($output, 0, -1); - - $output .= ']'; - } - $output .= '}'; - } - } - return $output; - } - - function error() { - return $this->errorMessage; - } - -} \ No newline at end of file + + +*/ + +# There is no good corresponding mysql_result function in mysqli. mysql_result is approximated here. +function mysqli_result($res, $row, $field=0) { + $res->data_seek($row); + $datarow = $res->fetch_array(); + return $datarow[$field]; +} + +class SQL { + + var $adapter = ""; + var $method = ""; + var $version = ""; + var $conn = ""; + var $options = ""; + var $errorMessage = ""; + var $db = ""; + + function __construct($connString, $user = "", $pass = "") { + list($this->adapter, $options) = explode(":", $connString, 2); + + if ($this->adapter != "sqlite") { + $this->adapter = "mysql"; + } + + $optionsList = explode(";", $options); + + foreach ($optionsList as $option) { + list($a, $b) = explode("=", $option); + $opt[$a] = $b; + } + + $this->options = $opt; + $database = (array_key_exists("database", $opt)) ? $opt['database'] : ""; + + if ($this->adapter == "sqlite" && substr(sqlite_libversion(), 0, 1) == "3" && class_exists("PDO") && in_array("sqlite", PDO::getAvailableDrivers())) { + $this->method = "pdo"; + + try + { + $this->conn = new PDO("sqlite:" . $database, null, null, array(PDO::ATTR_PERSISTENT => true)); + } + catch (PDOException $error) { + $this->conn = false; + $this->errorMessage = $error->getMessage(); + } + } else if ($this->adapter == "sqlite" && substr(sqlite_libversion(), 0, 1) == "2" && class_exists("PDO") && in_array("sqlite2", PDO::getAvailableDrivers())) { + $this->method = "pdo"; + + try + { + $this->conn = new PDO("sqlite2:" . $database, null, null, array(PDO::ATTR_PERSISTENT => true)); + } + catch (PDOException $error) { + $this->conn = false; + $this->errorMessage = $error->getMessage(); + } + } else if ($this->adapter == "sqlite") { + $this->method = "sqlite"; + $this->conn = sqlite_open($database, 0666, $sqliteError); + } else { + $this->method = "mysql"; + $host = (array_key_exists("host", $opt)) ? $opt['host'] : ""; + $this->conn = @mysqli_connect($host, $user, $pass); + } + + if ($this->conn && $this->method == "pdo") { + $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); + } + + if ($this->conn && $this->adapter == "mysql") { + $this->query("SET NAMES 'utf8'"); + } + + if ($this->conn && $database) { + $this->db = $database; + } + } + + function isConnected() { + return ($this->conn !== false); + } + + function disconnect() { + if ($this->conn) { + if ($this->method == "pdo") { + $this->conn = null; + } else if ($this->method == "mysql") { + mysqli_close($this->conn); + $this->conn = null; + } else if ($this->method == "sqlite") { + sqlite_close($this->conn); + $this->conn = null; + } + } + } + + function getAdapter() { + return $this->adapter; + } + + function getMethod() { + return $this->method; + } + + function getOptionValue($optKey) { + if (array_key_exists($optKey, $this->options)) { + return $this->options[$optKey]; + } else { + return false; + } + } + + function selectDB($db) { + if ($this->conn) { + if ($this->method == "mysql") { + $this->db = $db; + return (mysqli_select_db($this->conn, $db)); + } else { + return true; + } + } else { + return false; + } + } + + function query($queryText) { + if ($this->conn) { + if ($this->method == "pdo") { + $queryResult = $this->conn->prepare($queryText); + + if ($queryResult) + $queryResult->execute(); + + if (!$queryResult) { + $errorInfo = $this->conn->errorInfo(); + $this->errorMessage = $errorInfo[2]; + } + + return $queryResult; + } else if ($this->method == "mysql") { + $queryResult = @mysqli_query($this->conn, $queryText); + + if (!$queryResult) { + $this->errorMessage = mysqli_error($this->conn); + } + + return $queryResult; + } else if ($this->method == "sqlite") { + $queryResult = sqlite_query($this->conn, $queryText); + + if (!$queryResult) { + $this->errorMessage = sqlite_error_string(sqlite_last_error($this->conn)); + } + + return $queryResult; + } + } else { + return false; + } + } + + // Be careful using this function - when used with pdo, the pointer is moved + // to the end of the result set and the query needs to be rerun. Unless you + // actually need a count of the rows, use the isResultSet() function instead + function rowCount($resultSet) { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "pdo") { + return count($resultSet->fetchAll()); + } else if ($this->method == "mysql") { + return @mysqli_num_rows($resultSet); + } else if ($this->method == "sqlite") { + return @sqlite_num_rows($resultSet); + } + } + } + + function isResultSet($resultSet) { + if ($this->conn) { + if ($this->method == "pdo") { + return ($resultSet == true); + } else { + return ($this->rowCount($resultSet) > 0); + } + } + } + + function fetchArray($resultSet) { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "pdo") { + return $resultSet->fetch(PDO::FETCH_NUM); + } else if ($this->method == "mysql") { + return mysqli_fetch_row($resultSet); + } else if ($this->method == "sqlite") { + return sqlite_fetch_array($resultSet, SQLITE_NUM); + } + } + } + + function fetchAssoc($resultSet) { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "pdo") { + return $resultSet->fetch(PDO::FETCH_ASSOC); + } else if ($this->method == "mysql") { + return mysqli_fetch_assoc($resultSet); + } else if ($this->method == "sqlite") { + return sqlite_fetch_array($resultSet, SQLITE_ASSOC); + } + } + } + + function affectedRows($resultSet) { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "pdo") { + return $resultSet->rowCount(); + } else if ($this->method == "mysql") { +# return @mysqli_affected_rows($resultSet); + return @mysqli_affected_rows($this->conn); + } else if ($this->method == "sqlite") { + return sqlite_changes($resultSet); + } + } + } + + function result($resultSet, $targetRow, $targetColumn = "") { + if (!$resultSet) + return false; + + if ($this->conn) { + if ($this->method == "pdo") { + if ($targetColumn) { + $resultRow = $resultSet->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, $targetRow); + return $resultRow[$targetColumn]; + } else { + $resultRow = $resultSet->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_ABS, $targetRow); + return $resultRow[0]; + } + } else if ($this->method == "mysql") { + return mysqli_result($resultSet, $targetRow, $targetColumn); + } else if ($this->method == "sqlite") { + return sqlite_column($resultSet, $targetColumn); + } + } + } + + function listDatabases() { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("SHOW DATABASES"); + } else if ($this->adapter == "sqlite") { + return $this->db; + } + } + } + + function listTables() { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("SHOW TABLES"); + } else if ($this->adapter == "sqlite") { + return $this->query("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name"); + } + } + } + + function hasCharsetSupport() + { + if ($this->conn) { + if ($this->adapter == "mysql" && version_compare($this->getVersion(), "4.1", ">")) { + return true; + } else { + return false; + } + } + } + + function listCharset() { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("SHOW CHARACTER SET"); + } else if ($this->adapter == "sqlite") { + return ""; + } + } + } + + function listCollation() { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("SHOW COLLATION"); + } else if ($this->adapter == "sqlite") { + return ""; + } + } + } + + function insertId() { + if ($this->conn) { + if ($this->method == "pdo") { + return $this->conn->lastInsertId(); + } else if ($this->method == "mysql") { + return @mysqli_insert_id($this->conn); + } else if ($this->method == "sqlite") { + return sqlite_last_insert_rowid($this-conn); + } + } + } + + function escapeString($toEscape) { + if ($this->conn) { + if ($this->method == "pdo") { + $toEscape = $this->conn->quote($toEscape); + $toEscape = substr($toEscape, 1, -1); + return $toEscape; + } else if ($this->adapter == "mysql") { + return mysqli_real_escape_string($this->conn, $toEscape); + } else if ($this->adapter == "sqlite") { + return sqlite_escape_string($toEscape); + } + } + } + + function getVersion() { + if ($this->conn) { + // cache + if ($this->version) { + return $this->version; + } + + if ($this->adapter == "mysql") { + $verSql = mysqli_get_server_info($this->conn); + $version = explode("-", $verSql); + $this->version = $version[0]; + return $this->version; + } else if ($this->adapter == "sqlite") { + $this->version = sqlite_libversion(); + return $this->version; + } + } + + } + + // returns the number of rows in a table + function tableRowCount($table) { + if ($this->conn) { + if ($this->adapter == "mysql") { + $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table . "`"); + $count = (int)($this->result($countSql, 0, "RowCount")); + return $count; + } else if ($this->adapter == "sqlite") { + $countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $table . "'"); + $count = (int)($this->result($countSql, 0, "RowCount")); + return $count; + } + } + } + + // gets column info for a table + function describeTable($table) { + if ($this->conn) { + if ($this->adapter == "mysql") { + return $this->query("DESCRIBE `" . $table . "`"); + } else if ($this->adapter == "sqlite") { + $columnSql = $this->query("SELECT sql FROM sqlite_master where tbl_name = '" . $table . "'"); + $columnInfo = $this->result($columnSql, 0, "sql"); + $columnStart = strpos($columnInfo, '('); + $columns = substr($columnInfo, $columnStart+1, -1); + $columns = split(',[^0-9]', $columns); + + $columnList = array(); + + foreach ($columns as $column) { + $column = trim($column); + $columnSplit = explode(" ", $column, 2); + $columnName = $columnSplit[0]; + $columnType = (sizeof($columnSplit) > 1) ? $columnSplit[1] : ""; + $columnList[] = array($columnName, $columnType); + } + + return $columnList; + } + } + } + + /* + Return names, row counts etc for every database, table and view in a JSON string + */ + function getMetadata() { + $output = ''; + if ($this->conn) { + if ($this->adapter == "mysql" && version_compare($this->getVersion(), "5.0.0", ">=")) { + $this->selectDB("information_schema"); + $schemaSql = $this->query("SELECT `SCHEMA_NAME` FROM `SCHEMATA` ORDER BY `SCHEMA_NAME`"); + if ($this->rowCount($schemaSql)) { + while ($schema = $this->fetchAssoc($schemaSql)) { + $output .= '{"name": "' . $schema['SCHEMA_NAME'] . '"'; + // other interesting columns: TABLE_TYPE, ENGINE, TABLE_COLUMN and many more + $tableSql = $this->query("SELECT `TABLE_NAME`, `TABLE_ROWS` FROM `TABLES` WHERE `TABLE_SCHEMA`='" . $schema['SCHEMA_NAME'] . "' ORDER BY `TABLE_NAME`"); + if ($this->rowCount($tableSql)) { + $output .= ',"items": ['; + while ($table = $this->fetchAssoc($tableSql)) { + + if ($schema['SCHEMA_NAME'] == "information_schema") { + $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table['TABLE_NAME'] . "`"); + $rowCount = (int)($this->result($countSql, 0, "RowCount")); + } else { + $rowCount = (int)($table['TABLE_ROWS']); + } + + $output .= '{"name":"' . $table['TABLE_NAME'] . '","rowcount":' . $rowCount . '},'; + } + + if (substr($output, -1) == ",") + $output = substr($output, 0, -1); + + $output .= ']'; + } + $output .= '},'; + } + $output = substr($output, 0, -1); + } + } else if ($this->adapter == "mysql") { + $schemaSql = $this->listDatabases(); + + if ($this->rowCount($schemaSql)) { + while ($schema = $this->fetchArray($schemaSql)) { + $output .= '{"name": "' . $schema[0] . '"'; + + $this->selectDB($schema[0]); + $tableSql = $this->listTables(); + + if ($this->rowCount($tableSql)) { + $output .= ',"items": ['; + while ($table = $this->fetchArray($tableSql)) { + $countSql = $this->query("SELECT COUNT(*) AS `RowCount` FROM `" . $table[0] . "`"); + $rowCount = (int)($this->result($countSql, 0, "RowCount")); + $output .= '{"name":"' . $table[0] . '","rowcount":' . $rowCount . '},'; + } + + if (substr($output, -1) == ",") + $output = substr($output, 0, -1); + + $output .= ']'; + } + $output .= '},'; + } + $output = substr($output, 0, -1); + } + } else if ($this->adapter == "sqlite") { + $output .= '{"name": "' . $this->db . '"'; + + $tableSql = $this->listTables(); + + if ($tableSql) { + $output .= ',"items": ['; + while ($tableRow = $this->fetchArray($tableSql)) { + $countSql = $this->query("SELECT COUNT(*) AS 'RowCount' FROM '" . $tableRow[0] . "'"); + $rowCount = (int)($this->result($countSql, 0, "RowCount")); + $output .= '{"name":"' . $tableRow[0] . '","rowcount":' . $rowCount . '},'; + } + + if (substr($output, -1) == ",") + $output = substr($output, 0, -1); + + $output .= ']'; + } + $output .= '}'; + } + } + return $output; + } + + function error() { + return $this->errorMessage; + } + +} diff --git a/htdocs/sqlbuddy/includes/types.php b/htdocs/sqlbuddy/includes/types.php index 47cb55384..7fc56b2bf 100755 --- a/htdocs/sqlbuddy/includes/types.php +++ b/htdocs/sqlbuddy/includes/types.php @@ -1,80 +1,80 @@ - - -*/ - -$typeList[] = "varchar"; -$typeList[] = "char"; -$typeList[] = "text"; -$typeList[] = "tinytext"; -$typeList[] = "mediumtext"; -$typeList[] = "longtext"; -$typeList[] = "tinyint"; -$typeList[] = "smallint"; -$typeList[] = "mediumint"; -$typeList[] = "int"; -$typeList[] = "bigint"; -$typeList[] = "real"; -$typeList[] = "double"; -$typeList[] = "float"; -$typeList[] = "decimal"; -$typeList[] = "numeric"; -$typeList[] = "date"; -$typeList[] = "time"; -$typeList[] = "datetime"; -$typeList[] = "timestamp"; -$typeList[] = "tinyblob"; -$typeList[] = "blob"; -$typeList[] = "mediumblob"; -$typeList[] = "longblob"; -$typeList[] = "binary"; -$typeList[] = "varbinary"; -$typeList[] = "bit"; -$typeList[] = "enum"; -$typeList[] = "set"; - -$textDTs[] = "text"; -$textDTs[] = "mediumtext"; -$textDTs[] = "longtext"; - -$numericDTs[] = "tinyint"; -$numericDTs[] = "smallint"; -$numericDTs[] = "mediumint"; -$numericDTs[] = "int"; -$numericDTs[] = "bigint"; -$numericDTs[] = "real"; -$numericDTs[] = "double"; -$numericDTs[] = "float"; -$numericDTs[] = "decimal"; -$numericDTs[] = "numeric"; - -$binaryDTs[] = "tinyblob"; -$binaryDTs[] = "blob"; -$binaryDTs[] = "mediumblob"; -$binaryDTs[] = "longblob"; -$binaryDTs[] = "binary"; -$binaryDTs[] = "varbinary"; - -$sqliteTypeList[] = "varchar"; -$sqliteTypeList[] = "integer"; -$sqliteTypeList[] = "float"; -$sqliteTypeList[] = "varchar"; -$sqliteTypeList[] = "nvarchar"; -$sqliteTypeList[] = "text"; -$sqliteTypeList[] = "boolean"; -$sqliteTypeList[] = "clob"; -$sqliteTypeList[] = "blob"; -$sqliteTypeList[] = "timestamp"; -$sqliteTypeList[] = "numeric"; - + + +*/ + +$typeList[] = "varchar"; +$typeList[] = "char"; +$typeList[] = "text"; +$typeList[] = "tinytext"; +$typeList[] = "mediumtext"; +$typeList[] = "longtext"; +$typeList[] = "tinyint"; +$typeList[] = "smallint"; +$typeList[] = "mediumint"; +$typeList[] = "int"; +$typeList[] = "bigint"; +$typeList[] = "real"; +$typeList[] = "double"; +$typeList[] = "float"; +$typeList[] = "decimal"; +$typeList[] = "numeric"; +$typeList[] = "date"; +$typeList[] = "time"; +$typeList[] = "datetime"; +$typeList[] = "timestamp"; +$typeList[] = "tinyblob"; +$typeList[] = "blob"; +$typeList[] = "mediumblob"; +$typeList[] = "longblob"; +$typeList[] = "binary"; +$typeList[] = "varbinary"; +$typeList[] = "bit"; +$typeList[] = "enum"; +$typeList[] = "set"; + +$textDTs[] = "text"; +$textDTs[] = "mediumtext"; +$textDTs[] = "longtext"; + +$numericDTs[] = "tinyint"; +$numericDTs[] = "smallint"; +$numericDTs[] = "mediumint"; +$numericDTs[] = "int"; +$numericDTs[] = "bigint"; +$numericDTs[] = "real"; +$numericDTs[] = "double"; +$numericDTs[] = "float"; +$numericDTs[] = "decimal"; +$numericDTs[] = "numeric"; + +$binaryDTs[] = "tinyblob"; +$binaryDTs[] = "blob"; +$binaryDTs[] = "mediumblob"; +$binaryDTs[] = "longblob"; +$binaryDTs[] = "binary"; +$binaryDTs[] = "varbinary"; + +$sqliteTypeList[] = "varchar"; +$sqliteTypeList[] = "integer"; +$sqliteTypeList[] = "float"; +$sqliteTypeList[] = "varchar"; +$sqliteTypeList[] = "nvarchar"; +$sqliteTypeList[] = "text"; +$sqliteTypeList[] = "boolean"; +$sqliteTypeList[] = "clob"; +$sqliteTypeList[] = "blob"; +$sqliteTypeList[] = "timestamp"; +$sqliteTypeList[] = "numeric"; + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/index.php b/htdocs/sqlbuddy/index.php index 079c797e8..0f8743dff 100755 --- a/htdocs/sqlbuddy/index.php +++ b/htdocs/sqlbuddy/index.php @@ -1,22 +1,22 @@ - - -*/ - -include "functions.php"; - -loginCheck(false); - -outputPage(); - + + +*/ + +include "functions.php"; + +loginCheck(false); + +outputPage(); + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/insert.php b/htdocs/sqlbuddy/insert.php index 1ac68f968..0529a3a25 100755 --- a/htdocs/sqlbuddy/insert.php +++ b/htdocs/sqlbuddy/insert.php @@ -1,249 +1,249 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -requireDatabaseAndTableBeDefined(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($table)) - $structureSql = $conn->describeTable($table); - -if ($conn->isResultSet($structureSql) && $conn->getAdapter() == "mysql") { - while ($structureRow = $conn->fetchAssoc($structureSql)) { - $types[$structureRow['Field']] = $structureRow['Type']; - } - $structureSql = $conn->describeTable($table); -} - -if ($conn->isResultSet($structureSql) || sizeof($structureSql) > 0) { - - if ($_POST) { - - $insertFields = ""; - $insertValues = ""; - - foreach ($_POST as $key=>$value) { - - if ($conn->getAdapter() == "sqlite") { - $insertFields .= $key . ","; - } else { - $insertFields .= "`" . $key . "`,"; - } - - if (is_array($value)) { - $value = implode(",", $value); - } - - if (isset($types) && substr($value, 0, 2) == "0x" && isset($binaryDTs) && in_array($types[$key], $binaryDTs)) { - $insertValues .= $conn->escapeString(urldecode($value)) . ","; - } else { - $insertValues .= "'" . $conn->escapeString(urldecode($value)) . "',"; - } - - } - - $insertFields = substr($insertFields, 0, -1); - $insertValues = substr($insertValues, 0, -1); - - if ($conn->getAdapter() == "sqlite") { - $insertQuery = "INSERT INTO $table (" . $insertFields . ") VALUES (" . $insertValues . ")"; - } else { - $insertQuery = "INSERT INTO `$table` (" . $insertFields . ") VALUES (" . $insertValues . ")"; - } - - $conn->query($insertQuery) or ($dbError = $conn->error()); - - $insertId = $conn->insertId(); - - if (isset($dbError)) { - echo '
      ' . $dbError . '
      '; - } else { - echo '
      '; - echo __("Your data has been inserted into the database."); - if ($insertId) - echo ' (Id: ' . $insertId . ')'; - echo '
      '; - - ?> - - - - - -
      - - getAdapter() == "sqlite") { - - if (sizeof($structureSql) > 0) { - foreach ($structureSql as $column) { - - echo ''; - echo ''; - echo ""; - echo ""; - echo ' - - - getAdapter() == "mysql") { - - if ($conn->isResultSet($structureSql)) { - while ($structureRow = $conn->fetchAssoc($structureSql)) { - - preg_match("/^([a-z]+)(.([0-9]+).)?(.*)?$/", $structureRow['Type'], $matches); - - $curtype = $matches[1]; - $cursizeQuotes = $matches[2]; - $cursize = $matches[3]; - $curextra = $matches[4]; - - echo ''; - echo ''; - echo ""; - echo ""; - echo ' - - - - - - -
      '; - if (strpos($column[1], "primary key") > 0) echo ''; - echo $column[0]; - if (strpos($column[1], "primary key") > 0) echo ''; - echo " " . $column[1] . '
      '; - - if (strpos($column[1], "text") !== false) { - echo ''; - } else { - echo ''; - } - - ?> - -
      '; - if ($structureRow['Key'] == 'PRI') echo ''; - echo $structureRow['Field']; - if ($structureRow['Key'] == 'PRI') echo ''; - echo " " . $curtype . $cursizeQuotes . ' ' . $structureRow['Extra'] . '
      '; - if ($structureRow['Type'] == "text") { - echo ''; - } - elseif (substr($structureRow['Type'], 0, 4) == "enum") { - $trimmed = substr($structureRow['Type'], 6, -2); - $listOptions = explode("','", $trimmed); - echo ''; - } - elseif (substr($structureRow['Type'], 0, 3) == "set") { - $trimmed = substr($structureRow['Type'], 5, -2); - $listOptions = explode("','", $trimmed); - foreach ($listOptions as $option) { - $id = $option . rand(1, 1000); - echo '
      '; - } - } else { - echo ''; - } - - ?> - -
      - " /> -
      -
      - - - - - -
      -

      -

      -
      - - + +*/ + +include "functions.php"; + +loginCheck(); + +requireDatabaseAndTableBeDefined(); + +if (isset($db)) + $conn->selectDB($db); + +if (isset($table)) + $structureSql = $conn->describeTable($table); + +if ($conn->isResultSet($structureSql) && $conn->getAdapter() == "mysql") { + while ($structureRow = $conn->fetchAssoc($structureSql)) { + $types[$structureRow['Field']] = $structureRow['Type']; + } + $structureSql = $conn->describeTable($table); +} + +if ($conn->isResultSet($structureSql) || sizeof($structureSql) > 0) { + + if ($_POST) { + + $insertFields = ""; + $insertValues = ""; + + foreach ($_POST as $key=>$value) { + + if ($conn->getAdapter() == "sqlite") { + $insertFields .= $key . ","; + } else { + $insertFields .= "`" . $key . "`,"; + } + + if (is_array($value)) { + $value = implode(",", $value); + } + + if (isset($types) && substr($value, 0, 2) == "0x" && isset($binaryDTs) && in_array($types[$key], $binaryDTs)) { + $insertValues .= $conn->escapeString(urldecode($value)) . ","; + } else { + $insertValues .= "'" . $conn->escapeString(urldecode($value)) . "',"; + } + + } + + $insertFields = substr($insertFields, 0, -1); + $insertValues = substr($insertValues, 0, -1); + + if ($conn->getAdapter() == "sqlite") { + $insertQuery = "INSERT INTO $table (" . $insertFields . ") VALUES (" . $insertValues . ")"; + } else { + $insertQuery = "INSERT INTO `$table` (" . $insertFields . ") VALUES (" . $insertValues . ")"; + } + + $conn->query($insertQuery) or ($dbError = $conn->error()); + + $insertId = $conn->insertId(); + + if (isset($dbError)) { + echo '
      ' . $dbError . '
      '; + } else { + echo '
      '; + echo __("Your data has been inserted into the database."); + if ($insertId) + echo ' (Id: ' . $insertId . ')'; + echo '
      '; + + ?> + + + + + +
      + + getAdapter() == "sqlite") { + + if (sizeof($structureSql) > 0) { + foreach ($structureSql as $column) { + + echo ''; + echo ''; + echo ""; + echo ""; + echo ' + + + getAdapter() == "mysql") { + + if ($conn->isResultSet($structureSql)) { + while ($structureRow = $conn->fetchAssoc($structureSql)) { + + preg_match("/^([a-z]+)(.([0-9]+).)?(.*)?$/", $structureRow['Type'], $matches); + + $curtype = $matches[1]; + $cursizeQuotes = $matches[2]; + $cursize = $matches[3]; + $curextra = $matches[4]; + + echo ''; + echo ''; + echo ""; + echo ""; + echo ' + + + + + + +
      '; + if (strpos($column[1], "primary key") > 0) echo ''; + echo $column[0]; + if (strpos($column[1], "primary key") > 0) echo ''; + echo " " . $column[1] . '
      '; + + if (strpos($column[1], "text") !== false) { + echo ''; + } else { + echo ''; + } + + ?> + +
      '; + if ($structureRow['Key'] == 'PRI') echo ''; + echo $structureRow['Field']; + if ($structureRow['Key'] == 'PRI') echo ''; + echo " " . $curtype . $cursizeQuotes . ' ' . $structureRow['Extra'] . '
      '; + if ($structureRow['Type'] == "text") { + echo ''; + } + elseif (substr($structureRow['Type'], 0, 4) == "enum") { + $trimmed = substr($structureRow['Type'], 6, -2); + $listOptions = explode("','", $trimmed); + echo ''; + } + elseif (substr($structureRow['Type'], 0, 3) == "set") { + $trimmed = substr($structureRow['Type'], 5, -2); + $listOptions = explode("','", $trimmed); + foreach ($listOptions as $option) { + $id = $option . rand(1, 1000); + echo '
      '; + } + } else { + echo ''; + } + + ?> + +
      + " /> +
      +
      + + + + + +
      +

      +

      +
      + + \ No newline at end of file diff --git a/htdocs/sqlbuddy/js/core.js b/htdocs/sqlbuddy/js/core.js index 466d40a4c..036f22424 100755 --- a/htdocs/sqlbuddy/js/core.js +++ b/htdocs/sqlbuddy/js/core.js @@ -1,839 +1,839 @@ -var sb; - -var shiftPressed; -var lastActiveRow = -1; -var clearPanesOnLoad = false; - -var activeWindow; -var animationStack = []; - -var viewportSize = [0, 0]; - -function f(g) { - if (g == undefined || g == "undefined" || g == null) - return ""; - else - return g; -} - -var $E = function(selector, filter) { - return ($(filter) || document).getElement(selector); -}; - -var $ES = function(selector, filter) { - return ($(filter) || document).getElements(selector); -}; - -window.addEvent("domready", function() { - document.addEvent("keydown", function(e) { - var ev = new Event(e); - if (ev.shift) - shiftPressed = true; - }); - - document.addEvent("keyup", function() { - shiftPressed = false; - }); - - // to disable keyboard shortcuts, comment out the following line - window.addEvent("keydown", runKeyboardShortcuts); - - sb = new Page(); - - initializeSidemenu(); - - sb.loadHash(); - sb.loadPage(); - - (function(){ sb.preload(); }).delay(500); - (function(){ sb.checkHashState(); }).periodical(75); - (function(){ - var winWidth = getWindowWidth(); - var winHeight = getWindowHeight(); - if (viewportSize[0] != winWidth || viewportSize[1] != winHeight) { - viewportSize = [winWidth, winHeight]; - sizePage(); - } - }).periodical(175); - (function(){ autoExpandTextareas(); }).periodical(500); -}); - -function Page() { - this.page = "home.php"; - this.db; - this.table; - this.topTabSet = 0; - this.topTab = 0; - this.s; - this.view; - this.sortDir; - this.sortKey; - - this.$GUID = 1; - - this.pane; - this.grid; - this.gridHeader; - this.leftChecks; - - this.hashMemory = ""; - - this.submenuHeights = []; - this.submenuIds = []; - this.tableRowCounts = []; - - this.topTabs = [new TopTabGroup("Main"), new TopTabGroup("Database"), new TopTabGroup("Table")]; - - if (showUsersMenu) { - this.topTabs[0].addTab(gettext("Home"), "home.php").addTab(gettext("Users"), "users.php").addTab(gettext("Query"), "query.php").addTab(gettext("Import"), "import.php").addTab(gettext("Export"), "export.php"); - } else { - this.topTabs[0].addTab(gettext("Home"), "home.php").addTab(gettext("Query"), "query.php").addTab(gettext("Import"), "import.php").addTab(gettext("Export"), "export.php"); - } - - this.topTabs[1].addTab(gettext("Overview"), "dboverview.php").addTab(gettext("Query"), "query.php").addTab(gettext("Import"), "import.php").addTab(gettext("Export"), "export.php"); - this.topTabs[2].addTab(gettext("Browse"), "browse.php").addTab(gettext("Structure"), "structure.php").addTab(gettext("Insert"), "insert.php").addTab(gettext("Query"), "query.php").addTab(gettext("Import"), "import.php").addTab(gettext("Export"), "export.php"); - -} - -Page.prototype.loadPage = function() { - if (this.page == "browse.php" && parseInt(this.tableRowCounts[this.db + "_" + this.table]) == 0) { - this.page = "structure.php"; - this.topTab = 1; - } - - var pageUrl = ""; - if (f(this.s)) - pageUrl += "s=" + this.s + "&"; - if (f(this.sortDir)) - pageUrl += "sortDir=" + this.sortDir + "&"; - if (f(this.sortKey)) - pageUrl += "sortKey=" + this.sortKey + "&"; - pageUrl = pageUrl.substring(0, pageUrl.length - 1); - - if (this.page == "editcolumn.php") { - this.page = "structure.php"; - this.topTab = 1; - } else if (this.page == "edituser.php") { - this.page = "users.php"; - this.topTab = 1; - } else if (this.page == "edit.php") { - this.page = "browse.php"; - this.topTab = 0; - } - - clearPanesOnLoad = true; - var x = new XHR({url: this.page, onSuccess: finishTabLoad}).send(pageUrl); -} - -Page.prototype.refreshTopTabSet = function(setNum) { - if (f(setNum)) - this.topTabSet = setNum; - - var topTabsElem = $E('#toptabs ul'); - topTabsElem.empty(); - var loopStop = this.topTabs[this.topTabSet].tabCounter; - var browseIsActive = true; - var currentTab, rowCount, tabId, tabLiObj, tabAObj, tabACount; - - for (var i=0; i"); - - if (m == 1) - prompter += gettext("The following query will be run:"); - else - prompter += gettext("The following queries will be run:"); - - prompter += "
      " + formattedQuery + "
      "; - } - - buildList = encodeURIComponent(buildList.replace(/\n/g, "")); - buildList = buildList.replace(/'/g, "\\'"); - - buildUrl = parameter + "=" + buildList; - - if (sb.page == "browse.php") { - if (f(sb.view)) - buildUrl += "&view=" + sb.view; - - if (f(sb.s)) - buildUrl += "&s=" + sb.s; - - if (f(sb.sortKey)) - buildUrl += "&sortKey=" + sb.sortKey - - if (f(sb.sortDir)) - buildUrl += "&sortDir=" + sb.sortDir; - } - - showDialog(gettext("Confirm"), - prompter, - "var x = new XHR({url: \"" + sb.page + "\", onSuccess: finishTabLoad}).send(\"" + buildUrl + "\");" - ); - } - } -} - -function showDialog(title, content, action) { - createWindow(title, content, {isDialog: true, dialogAction: action}); -} - -function submitForm(formId) { - var theForm = $(formId); - var action = theForm.get("action"); - - if (!action) - action = sb.page; - - var x = new XHR({url: action, onSuccess: finishTabLoad}).send(theForm.toQueryString()); -} - -var XHR = new Class({ - - Extends: Request, - - initialize: function(options) { - - if (!options.url) - options.url = sb.page; - - if (options.url.indexOf("?") == -1) - options.url += "?ajaxRequest=" + sb.$GUID++; - else - options.url += "&ajaxRequest=" + sb.$GUID++; - - options.url += "&requestKey=" + requestKey; - - if (f(sb.db)) - options.url += "&db=" + sb.db; - if (f(sb.table)) - options.url += "&table=" + sb.table; - - this.parent(options); - - if (options && options.showLoader != false) { - show('load'); - - this.addEvent("onSuccess", function() { - hide('load'); - }); - - this.addEvent("onFailure", function() { - hide('load'); - createWindow(gettext("Error"), gettext("There was an error receiving data from the server."), {isDismissible: true}); - }); - } - }, - - // redefined to avoid auto script execution - success: function(text, xml) { - this.onSuccess(text, xml); - } - -}); - -function gettext(str) { - if (f(getTextArr[str]) != "") - return getTextArr[str]; - else - return str; -} - -function printf() { - var argv = printf.arguments; - var argc = parseInt(argv.length); - - var inputString = argv[0]; - - for (var i=1; i' + title + '

      '; - windowHeader.set('html', windowHeaderContent); - windowMain.appendChild(windowHeader); - - if (options.isDialog && f(options.dialogAction) != "") { - content += '
       
      '; - } else if (options.isDismissible) { - content += '
       
      '; - } - - var windowInner = new Element('div'); - windowInner.className = 'fulltextinner'; - var innerContent = '
      ' + content + '
      '; - - if (!(options.isDialog || options.isDismissible)) { - innerContent += '
      '; - } - - innerContent += '
      '; - - windowInner.set('html', innerContent); - windowMain.appendChild(windowInner); - textWindow.appendChild(windowMain); - - var windowFooter = new Element('div'); - windowFooter.className = 'fulltextfooter'; - var footerCode = '
       
      '; - windowFooter.set('html', footerCode); - - textWindow.appendChild(windowFooter); - document.body.appendChild(textWindow); - - if (options.isDialog == true && f(options.dialogAction) != "") { - var okayClick = $(windowId + 'Click'); - okayClick.addEvent("click", function() { - closeWindow(windowId); - eval(options.dialogAction); - }); - okayClick.focus(); - } else if (options.isDismissible == true) { - var okayClick = $(windowId + 'Click'); - okayClick.focus(); - } else if (!(options.isDialog || options.isDismissible)) { - var resizeHandle = $('resize' + windowId); - resizeHandle.addEvent("mousedown", startResize); - } - - return windowId; -} - -function show(a) { - $(a).style.display = ''; -} - -function hide(a) { - $(a).style.display = 'none'; -} - -function runKeyboardShortcuts(e) { - var event = new Event(e); - if (!((event.target.nodeName == "INPUT" && (event.target.type == "text" || event.target.type == "password")) || (event.target.nodeName == "TEXTAREA") || event.meta || event.control)) { - if (event.key == "a") { - checkAll(); - } else if (event.key == "n") { - checkNone(); - } else if (event.key == "e") { - if (sb.page == "browse.php" || sb.page == "structure.php" || sb.page == "users.php") - editSelectedRows(); - } else if (event.key == "d") { - if (sb.page == "structure.php") - deleteSelectedColumns(); - else if (sb.page == "users.php") - deleteSelectedUsers(); - else if (sb.page == "browse.php") - deleteSelectedRows(); - else if (sb.page == "dboverview.php") - dropSelectedTables(); - } else if (event.key == "r") { - sb.loadPage(); - } else if (event.key == "f" && sb.page == "browse.php") { - if ($('firstNav')) - eval($('firstNav').get("onclick")); - } else if (event.key == "g" && sb.page == "browse.php") { - if ($('prevNav')) - eval($('prevNav').get("onclick")); - } else if (event.key == "h" && sb.page == "browse.php") { - if ($('nextNav')) - eval($('nextNav').get("onclick")); - } else if (event.key == "l" && sb.page == "browse.php") { - if ($('lastNav')) - eval($('lastNav').get("onclick")); - } else if (event.key == "q") { - var tabId = 0; - while (sb.getTabUrl(tabId) != "query.php") { - tabId++; - } - topTabLoad(tabId); - - event.stop(); - event.stopPropagation(); - } else if (event.key == "o" && sb.page == "dboverview.php") { - optimizeSelectedTables(); - } - - } else if (event.target.nodeName == "TEXTAREA" && event.control && event.key == "enter") { - var curr = $(event.target); - while (curr && curr.get('tag') != "form") { - curr = $(curr.parentNode); - } - - if (curr) { - currButton = $E("input[type=submit]", curr); - if (currButton) { - currButton.click(); - } - } - } -} - -function getWindowWidth() { - if (window.innerWidth) - return window.innerWidth; - else - return document.documentElement.clientWidth; -} - -function getWindowHeight() { - if (window.innerHeight) - return window.innerHeight; - else - return document.documentElement.clientHeight; -} - -function getScrollbarWidth() { - - var outer = new Element('div'); - outer.style.position = 'absolute'; - outer.style.top = '-1000px'; - outer.style.left = '-1000px'; - outer.style.width = '100px'; - outer.style.height = '50px'; - outer.style.overflow = 'hidden'; - - var inner = new Element('div'); - inner.style.width = '100%'; - inner.style.height = '200px'; - - outer.appendChild(inner); - document.body.appendChild(outer); - - var w1 = inner.offsetWidth; - outer.style.overflow = "auto"; - var w2 = inner.offsetWidth; - - document.body.removeChild(outer); - - return (w1 - w2); -}; - -function addAnimation(id, finish) { - var elem = $(id); - - //remove duplicates - for (var i in animationStack) { - if (animationStack[i][0] == elem) - animationStack.splice(i, 1); - } - - var start = elem.offsetHeight; - - var change = finish - start; - - var totalFrames = 15; - - if (window.gecko) - totalFrames -= 5; - - animationStack.push([elem, start, change, 0, totalFrames]); - if (animationStack.length == 1) - animate(); -} - -function animate() { - var j, elem, start, change, currentFrame, totalFrames; - for (var i = 0; i < animationStack.length; i++) { - - j = parseInt(i); - - elem = animationStack[j][0]; - start = animationStack[j][1]; - change = animationStack[j][2]; - animationStack[j][3] += 1; - currentFrame = animationStack[j][3]; - totalFrames = animationStack[j][4]; - - var newHeight = sineInOut(currentFrame, start, change, totalFrames); - - elem.style.height = newHeight + "px"; - - if (currentFrame >= totalFrames) { - animationStack.splice(j, 1); - - //if the menu is expanded, take off the explicit height attribute - if (elem.style.height != "0px") { - elem.style.height = ''; - } - } - } - if (animationStack.length > 0) - setTimeout('animate()', 25); -} - -function sineInOut(t, b, c, d) { - return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; +var sb; + +var shiftPressed; +var lastActiveRow = -1; +var clearPanesOnLoad = false; + +var activeWindow; +var animationStack = []; + +var viewportSize = [0, 0]; + +function f(g) { + if (g == undefined || g == "undefined" || g == null) + return ""; + else + return g; +} + +var $E = function(selector, filter) { + return ($(filter) || document).getElement(selector); +}; + +var $ES = function(selector, filter) { + return ($(filter) || document).getElements(selector); +}; + +window.addEvent("domready", function() { + document.addEvent("keydown", function(e) { + var ev = new Event(e); + if (ev.shift) + shiftPressed = true; + }); + + document.addEvent("keyup", function() { + shiftPressed = false; + }); + + // to disable keyboard shortcuts, comment out the following line + window.addEvent("keydown", runKeyboardShortcuts); + + sb = new Page(); + + initializeSidemenu(); + + sb.loadHash(); + sb.loadPage(); + + (function(){ sb.preload(); }).delay(500); + (function(){ sb.checkHashState(); }).periodical(75); + (function(){ + var winWidth = getWindowWidth(); + var winHeight = getWindowHeight(); + if (viewportSize[0] != winWidth || viewportSize[1] != winHeight) { + viewportSize = [winWidth, winHeight]; + sizePage(); + } + }).periodical(175); + (function(){ autoExpandTextareas(); }).periodical(500); +}); + +function Page() { + this.page = "home.php"; + this.db; + this.table; + this.topTabSet = 0; + this.topTab = 0; + this.s; + this.view; + this.sortDir; + this.sortKey; + + this.$GUID = 1; + + this.pane; + this.grid; + this.gridHeader; + this.leftChecks; + + this.hashMemory = ""; + + this.submenuHeights = []; + this.submenuIds = []; + this.tableRowCounts = []; + + this.topTabs = [new TopTabGroup("Main"), new TopTabGroup("Database"), new TopTabGroup("Table")]; + + if (showUsersMenu) { + this.topTabs[0].addTab(gettext("Home"), "home.php").addTab(gettext("Users"), "users.php").addTab(gettext("Query"), "query.php").addTab(gettext("Import"), "import.php").addTab(gettext("Export"), "export.php"); + } else { + this.topTabs[0].addTab(gettext("Home"), "home.php").addTab(gettext("Query"), "query.php").addTab(gettext("Import"), "import.php").addTab(gettext("Export"), "export.php"); + } + + this.topTabs[1].addTab(gettext("Overview"), "dboverview.php").addTab(gettext("Query"), "query.php").addTab(gettext("Import"), "import.php").addTab(gettext("Export"), "export.php"); + this.topTabs[2].addTab(gettext("Browse"), "browse.php").addTab(gettext("Structure"), "structure.php").addTab(gettext("Insert"), "insert.php").addTab(gettext("Query"), "query.php").addTab(gettext("Import"), "import.php").addTab(gettext("Export"), "export.php"); + +} + +Page.prototype.loadPage = function() { + if (this.page == "browse.php" && parseInt(this.tableRowCounts[this.db + "_" + this.table]) == 0) { + this.page = "structure.php"; + this.topTab = 1; + } + + var pageUrl = ""; + if (f(this.s)) + pageUrl += "s=" + this.s + "&"; + if (f(this.sortDir)) + pageUrl += "sortDir=" + this.sortDir + "&"; + if (f(this.sortKey)) + pageUrl += "sortKey=" + this.sortKey + "&"; + pageUrl = pageUrl.substring(0, pageUrl.length - 1); + + if (this.page == "editcolumn.php") { + this.page = "structure.php"; + this.topTab = 1; + } else if (this.page == "edituser.php") { + this.page = "users.php"; + this.topTab = 1; + } else if (this.page == "edit.php") { + this.page = "browse.php"; + this.topTab = 0; + } + + clearPanesOnLoad = true; + var x = new XHR({url: this.page, onSuccess: finishTabLoad}).send(pageUrl); +} + +Page.prototype.refreshTopTabSet = function(setNum) { + if (f(setNum)) + this.topTabSet = setNum; + + var topTabsElem = $E('#toptabs ul'); + topTabsElem.empty(); + var loopStop = this.topTabs[this.topTabSet].tabCounter; + var browseIsActive = true; + var currentTab, rowCount, tabId, tabLiObj, tabAObj, tabACount; + + for (var i=0; i"); + + if (m == 1) + prompter += gettext("The following query will be run:"); + else + prompter += gettext("The following queries will be run:"); + + prompter += "
      " + formattedQuery + "
      "; + } + + buildList = encodeURIComponent(buildList.replace(/\n/g, "")); + buildList = buildList.replace(/'/g, "\\'"); + + buildUrl = parameter + "=" + buildList; + + if (sb.page == "browse.php") { + if (f(sb.view)) + buildUrl += "&view=" + sb.view; + + if (f(sb.s)) + buildUrl += "&s=" + sb.s; + + if (f(sb.sortKey)) + buildUrl += "&sortKey=" + sb.sortKey + + if (f(sb.sortDir)) + buildUrl += "&sortDir=" + sb.sortDir; + } + + showDialog(gettext("Confirm"), + prompter, + "var x = new XHR({url: \"" + sb.page + "\", onSuccess: finishTabLoad}).send(\"" + buildUrl + "\");" + ); + } + } +} + +function showDialog(title, content, action) { + createWindow(title, content, {isDialog: true, dialogAction: action}); +} + +function submitForm(formId) { + var theForm = $(formId); + var action = theForm.get("action"); + + if (!action) + action = sb.page; + + var x = new XHR({url: action, onSuccess: finishTabLoad}).send(theForm.toQueryString()); +} + +var XHR = new Class({ + + Extends: Request, + + initialize: function(options) { + + if (!options.url) + options.url = sb.page; + + if (options.url.indexOf("?") == -1) + options.url += "?ajaxRequest=" + sb.$GUID++; + else + options.url += "&ajaxRequest=" + sb.$GUID++; + + options.url += "&requestKey=" + requestKey; + + if (f(sb.db)) + options.url += "&db=" + sb.db; + if (f(sb.table)) + options.url += "&table=" + sb.table; + + this.parent(options); + + if (options && options.showLoader != false) { + show('load'); + + this.addEvent("onSuccess", function() { + hide('load'); + }); + + this.addEvent("onFailure", function() { + hide('load'); + createWindow(gettext("Error"), gettext("There was an error receiving data from the server."), {isDismissible: true}); + }); + } + }, + + // redefined to avoid auto script execution + success: function(text, xml) { + this.onSuccess(text, xml); + } + +}); + +function gettext(str) { + if (f(getTextArr[str]) != "") + return getTextArr[str]; + else + return str; +} + +function printf() { + var argv = printf.arguments; + var argc = parseInt(argv.length); + + var inputString = argv[0]; + + for (var i=1; i' + title + '

      '; + windowHeader.set('html', windowHeaderContent); + windowMain.appendChild(windowHeader); + + if (options.isDialog && f(options.dialogAction) != "") { + content += '
       
      '; + } else if (options.isDismissible) { + content += '
       
      '; + } + + var windowInner = new Element('div'); + windowInner.className = 'fulltextinner'; + var innerContent = '
      ' + content + '
      '; + + if (!(options.isDialog || options.isDismissible)) { + innerContent += '
      '; + } + + innerContent += '
      '; + + windowInner.set('html', innerContent); + windowMain.appendChild(windowInner); + textWindow.appendChild(windowMain); + + var windowFooter = new Element('div'); + windowFooter.className = 'fulltextfooter'; + var footerCode = '
       
      '; + windowFooter.set('html', footerCode); + + textWindow.appendChild(windowFooter); + document.body.appendChild(textWindow); + + if (options.isDialog == true && f(options.dialogAction) != "") { + var okayClick = $(windowId + 'Click'); + okayClick.addEvent("click", function() { + closeWindow(windowId); + eval(options.dialogAction); + }); + okayClick.focus(); + } else if (options.isDismissible == true) { + var okayClick = $(windowId + 'Click'); + okayClick.focus(); + } else if (!(options.isDialog || options.isDismissible)) { + var resizeHandle = $('resize' + windowId); + resizeHandle.addEvent("mousedown", startResize); + } + + return windowId; +} + +function show(a) { + $(a).style.display = ''; +} + +function hide(a) { + $(a).style.display = 'none'; +} + +function runKeyboardShortcuts(e) { + var event = new Event(e); + if (!((event.target.nodeName == "INPUT" && (event.target.type == "text" || event.target.type == "password")) || (event.target.nodeName == "TEXTAREA") || event.meta || event.control)) { + if (event.key == "a") { + checkAll(); + } else if (event.key == "n") { + checkNone(); + } else if (event.key == "e") { + if (sb.page == "browse.php" || sb.page == "structure.php" || sb.page == "users.php") + editSelectedRows(); + } else if (event.key == "d") { + if (sb.page == "structure.php") + deleteSelectedColumns(); + else if (sb.page == "users.php") + deleteSelectedUsers(); + else if (sb.page == "browse.php") + deleteSelectedRows(); + else if (sb.page == "dboverview.php") + dropSelectedTables(); + } else if (event.key == "r") { + sb.loadPage(); + } else if (event.key == "f" && sb.page == "browse.php") { + if ($('firstNav')) + eval($('firstNav').get("onclick")); + } else if (event.key == "g" && sb.page == "browse.php") { + if ($('prevNav')) + eval($('prevNav').get("onclick")); + } else if (event.key == "h" && sb.page == "browse.php") { + if ($('nextNav')) + eval($('nextNav').get("onclick")); + } else if (event.key == "l" && sb.page == "browse.php") { + if ($('lastNav')) + eval($('lastNav').get("onclick")); + } else if (event.key == "q") { + var tabId = 0; + while (sb.getTabUrl(tabId) != "query.php") { + tabId++; + } + topTabLoad(tabId); + + event.stop(); + event.stopPropagation(); + } else if (event.key == "o" && sb.page == "dboverview.php") { + optimizeSelectedTables(); + } + + } else if (event.target.nodeName == "TEXTAREA" && event.control && event.key == "enter") { + var curr = $(event.target); + while (curr && curr.get('tag') != "form") { + curr = $(curr.parentNode); + } + + if (curr) { + currButton = $E("input[type=submit]", curr); + if (currButton) { + currButton.click(); + } + } + } +} + +function getWindowWidth() { + if (window.innerWidth) + return window.innerWidth; + else + return document.documentElement.clientWidth; +} + +function getWindowHeight() { + if (window.innerHeight) + return window.innerHeight; + else + return document.documentElement.clientHeight; +} + +function getScrollbarWidth() { + + var outer = new Element('div'); + outer.style.position = 'absolute'; + outer.style.top = '-1000px'; + outer.style.left = '-1000px'; + outer.style.width = '100px'; + outer.style.height = '50px'; + outer.style.overflow = 'hidden'; + + var inner = new Element('div'); + inner.style.width = '100%'; + inner.style.height = '200px'; + + outer.appendChild(inner); + document.body.appendChild(outer); + + var w1 = inner.offsetWidth; + outer.style.overflow = "auto"; + var w2 = inner.offsetWidth; + + document.body.removeChild(outer); + + return (w1 - w2); +}; + +function addAnimation(id, finish) { + var elem = $(id); + + //remove duplicates + for (var i in animationStack) { + if (animationStack[i][0] == elem) + animationStack.splice(i, 1); + } + + var start = elem.offsetHeight; + + var change = finish - start; + + var totalFrames = 15; + + if (window.gecko) + totalFrames -= 5; + + animationStack.push([elem, start, change, 0, totalFrames]); + if (animationStack.length == 1) + animate(); +} + +function animate() { + var j, elem, start, change, currentFrame, totalFrames; + for (var i = 0; i < animationStack.length; i++) { + + j = parseInt(i); + + elem = animationStack[j][0]; + start = animationStack[j][1]; + change = animationStack[j][2]; + animationStack[j][3] += 1; + currentFrame = animationStack[j][3]; + totalFrames = animationStack[j][4]; + + var newHeight = sineInOut(currentFrame, start, change, totalFrames); + + elem.style.height = newHeight + "px"; + + if (currentFrame >= totalFrames) { + animationStack.splice(j, 1); + + //if the menu is expanded, take off the explicit height attribute + if (elem.style.height != "0px") { + elem.style.height = ''; + } + } + } + if (animationStack.length > 0) + setTimeout('animate()', 25); +} + +function sineInOut(t, b, c, d) { + return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; } \ No newline at end of file diff --git a/htdocs/sqlbuddy/js/helpers.js b/htdocs/sqlbuddy/js/helpers.js index 7cb8294ac..23b9b2d61 100755 --- a/htdocs/sqlbuddy/js/helpers.js +++ b/htdocs/sqlbuddy/js/helpers.js @@ -1,1240 +1,1240 @@ -function clearPanes() { - $('innercontent').empty(); -} - -function toggleMenuClick(e) { - var event = new Event(e); - var menuId = event.target.parentNode.parentNode.id; - toggleMenu(menuId.substring(2)); -} - -function toggleMenu(b, forceExpand) { - b = parseInt(b); - var menuId = "db" + b; - var menu = $(menuId); - var sub = "sublist" + b; - - if (!menu.hasClass("expanded")) { - // accordion - var openMenus = $ES(".expanded"); - for (var m=0; m= 0 && lastActiveRow != rowId) { - if (context) { - var grid = $E('.gridscroll', $(context)); - var checks = $E('.leftchecks', $(context)).childNodes; - } else { - var grid = sb.grid; - var checks = sb.leftChecks.childNodes; - } - - if (rowId < lastActiveRow) { - for (var i=rowId+1; ilastActiveRow; i--) { - checks[i].firstChild.firstChild.checked = checks[rowId].firstChild.firstChild.checked; - highlightDataRow(i, context); - } - } - } - lastActiveRow = rowId; -} - -function highlightDataRow(i, context) { - if (context) { - var grid = $(context); - var rows = $E('.gridscroll', grid).childNodes; - var lc = $E('.leftchecks', grid).childNodes; - } else { - var rows = sb.grid.childNodes; - var lc = sb.leftChecks.childNodes; - } - - if (lc[i].firstChild.firstChild.checked == true) { - if (rows[i].className.indexOf("highlighted") == -1) { - rows[i].className += " highlighted"; - lc[i].className += " highlighted"; - } - } else { - if (rows[i].className.indexOf("highlighted") != -1) { - rows[i].className = rows[i].className.replace("highlighted", ""); - lc[i].className = lc[i].className.replace("highlighted", ""); - } - } -} - -function editSelectedRows() { - var grid = sb.grid; - if (f(grid)) { - var editParts = ""; - var count = 0; - var inputs = $ES("input", sb.leftChecks); - for (var i=0; i 0) { - if (sb.page == "structure.php") - var loadPage = "editcolumn.php"; - else if (sb.page == "users.php") - var loadPage = "edituser.php"; - else - var loadPage = "edit.php"; - - editParts = editParts.substring(0, editParts.length - 2); - sb.topTabs[sb.topTabSet].addTab("Edit", loadPage, true); - sb.page = loadPage; - var x = new XHR({url: loadPage, onSuccess: finishTabLoad}).send("editParts=" + editParts); - } - } -} - -function saveEdit(formId) { - var form = $(formId); - var queryPart = form.get("querypart"); - var x = new XHR({url: "ajaxsaveedit.php?queryPart=" + queryPart + "&form=" + formId, onSuccess: updateAfterEdit}).send(form.toQueryString()); -} - -function saveColumnEdit(formId) { - var form = $(formId); - var changes = getFieldSummary(form); - var columnQuery = "ALTER TABLE `" + sb.table + "` CHANGE `" + form.get("querypart") + "` " + changes; - var x = new XHR({url: "ajaxsavecolumnedit.php?form=" + formId, onSuccess: updateAfterEdit}).send("runQuery=" + columnQuery); -} - -function saveUserEdit(formId) { - var form = $(formId); - var x = new XHR({url: "ajaxsaveuseredit.php?form=" + formId + "&user=" + form.get("querypart"), onSuccess: updateAfterEdit}).send(form.toQueryString()); -} - -function updateAfterEdit(json) { - var response = eval('(' + json + ')'); - var formu = $(response.formupdate); - if (response.errormess == "") { - showUpdateMessage(formu); - } else { - var errHandle = $E('.errormessage', formu); - errHandle.style.display = ''; - errHandle.set('text', response.errormess); - } - sizePage(); - clearPanesOnLoad = true; -} - -function showUpdateMessage(formu) { - // hide other messages - hideUpdateMessages(); - - formu.innerHTML = ""; - var updateId = sb.$GUID++; - var updateDiv = new Element("div", { - 'class': 'insertmessage', - 'id': 'update' + updateId - }).set('text', gettext("Your changes were saved to the database.")); - formu.appendChild(updateDiv); - yellowFade($('update' + updateId)); - setTimeout(hideUpdateMessages, 1250); -} - -function hideUpdateMessages() { - var updates = $ES(".insertmessage"); - var edits = $ES(".edit"); - - if (edits.length == 0) { - updates[0].set('text', gettext("Redirecting...")); - - for (var i=1; i" + emptyQuery + "", - "var x = new XHR({url: \"ajaxquery.php\", onSuccess: emptyTableCallback}).send(\"query=" + encodeURIComponent(emptyQuery) + "&silent=1\")" - ); - } -} - -function emptyTableCallback() { - sb.tableRowCounts[sb.db + "_" + sb.table] = "0"; - subTabLoad(sb.db, sb.table); -} - -function confirmDropTable() { - var table = sb.table; - if (f(table)) { - var dropQuery = "DROP TABLE " + returnQuote() + table + returnQuote(); - var targ = $(getSubMenuId(sb.db, sb.table)); - while (!targ.hasClass("sublist")) { - targ = targ.parentNode; - } - var toRecalculate = targ.id; - showDialog(gettext("Confirm"), - printf(gettext("Are you sure you want to drop the '%s' table? This will delete the table and all data inside of it. The following query will be run:"), table) + "
      " + dropQuery + "
      ", - "var x = new XHR({url: \"ajaxquery.php\"}).send(\"query=" + dropQuery + "&silent=1\"); $(getSubMenuId(sb.db, sb.table)).dispose(); databaseLoad(sb.db); recalculateSubmenuHeight(\"" + toRecalculate + "\");" - ); - } -} - -function optimizeTable() { - if (sb.table) { - var optimizeQuery = "OPTIMIZE TABLE `" + sb.table + "`;"; - var x = new XHR({url: "ajaxquery.php", onSuccess: function(){ sb.loadPage() } }).send("query=" + optimizeQuery + "&silent=1"); - } -} - -function confirmDropDatabase() { - var db = sb.db; - if (f(db)) { - var dropQuery = "DROP DATABASE `" + db + "`"; - showDialog(gettext("Confirm"), - printf(gettext("Are you sure you want to drop the database '%s'? This will delete the database, the tables inside the database, and all data inside of the tables. The following query will be run:"), db) + "
      " + dropQuery + "
      ", - "var x = new XHR({url: \"ajaxquery.php\"}).send(\"query=" + dropQuery + "&silent=1\"); $(getSubMenuId(sb.db, sb.table)).dispose(); sideMainClick(\"home.php\",\"hometab\");" - ); - } -} - -function editTable() { - var newName = $('RENAME').value; - var charSelect = $('RECHARSET'); - if (charSelect) - var newCharset = charSelect.options[charSelect.selectedIndex].value; - - var runQuery = ""; - - if (newName != sb.table && adapter == "mysql") { - runQuery += "RENAME TABLE `" + sb.table + "` TO `" + newName + "`;"; - } else if (newName != sb.table && adapter == "sqlite") { - runQuery += "ALTER TABLE '" + sb.table + "' RENAME TO '" + newName + "';"; - } - - if (f(newCharset) != "") { - runQuery += "ALTER TABLE `" + sb.table + "` CHARSET " + newCharset + ";"; - } - - if (f(runQuery) != "") { - $('RENAME').blur(); - var x = new XHR({url: "ajaxquery.php", onSuccess: editTableCallback}).send("query=" + runQuery + "&silent=1"); - } - - // defined interally on purpose - function editTableCallback() { - if (f(newName) != "" && newName != sb.table) { - var submenuItem = $(sb.submenuIds[sb.db + '_' + sb.table]); - submenuItem.firstChild.set('text', newName); - submenuItem.firstChild.href = "#page=browse&db=" + sb.db + "&table=" + newName + "&topTabSet=2"; - var subacount = new Element('span'); - subacount.className = "subcount"; - subacount.appendText("(" + approximateNumber(sb.tableRowCounts[sb.db + '_' + sb.table]) + ")"); - submenuItem.firstChild.appendChild(subacount); - - sb.submenuIds[sb.db + '_' + newName] = sb.submenuIds[sb.db + '_' + sb.table]; - sb.submenuIds[sb.db + '_' + sb.table] = ''; - sb.tableRowCounts[sb.db + '_' + newName] = sb.tableRowCounts[sb.db + '_' + sb.table]; - sb.tableRowCounts[sb.db + '_' + sb.table] = ''; - sb.table = newName; - sb.setHash(); - } - - $('editTableMessage').set('text', gettext("Successfully saved changes.")); - yellowFade($('editTableMessage')); - var clearTable = function() { - $('editTableMessage').empty(); - }; - - clearTable.delay(2000); - - clearPanesOnLoad = true; - } -} - -function editDatabase() { - var charSelect = $('DBRECHARSET'); - var newCharset = charSelect.options[charSelect.selectedIndex].value; - - if (f(newCharset) != "") { - var runQuery = "ALTER DATABASE `" + sb.db + "` CHARSET " + newCharset + ";"; - var x = new XHR({url: "ajaxquery.php", onSuccess: editDatabaseCallback}).send("query=" + runQuery + "&silent=1"); - } - - function editDatabaseCallback() { - $('editDatabaseMessage').set('text', gettext("Successfully saved changes.")); - yellowFade($('editDatabaseMessage')); - - var clearDatabase = function() { - $('editDatabaseMessage').empty(); - }; - - clearDatabase.delay(2000); - - clearPanesOnLoad = true; - } -} - -function runJavascriptContent() { - var scripts = $ES("script", sb.pane); - for (var i=0; i 0) { - for (var i=0; i" + name + ""; - else if (adapter == "sqlite") - fieldBuild = name; - else - fieldBuild = "`" + name + "`"; - - if (adapter == "sqlite") { - if (f(type)) - fieldBuild += " " + type; - if (f(size) && f(type)) - fieldBuild += "(" + size + ")"; - if (f(notnull)) - fieldBuild += " not null"; - if (f(key)) - fieldBuild += " " + key + " key"; - if (f(auto)) - fieldBuild += " autoincrement"; - if (f(unique)) - fieldBuild += " unique"; - if (f(defaultval)) - fieldBuild += " default '" + defaultval + "'"; - } else { - if (f(type)) - fieldBuild += " " + type; - if (f(values) && (type == "set" || type == "enum")) - fieldBuild += values + ""; - if (f(size) && f(type)) - fieldBuild += "(" + size + ")"; - if (f(unsign)) - fieldBuild += " unsigned"; - if (f(binary)) - fieldBuild += " binary"; - if (f(charset)) - fieldBuild += " charset " + charset; - if (f(notnull)) - fieldBuild += " not null"; - if (f(defaultval)) - fieldBuild += " default '" + defaultval + "'"; - if (f(auto)) - fieldBuild += " auto_increment"; - if (f(key)) - fieldBuild += " " + key + " key"; - } - - } - } - return fieldBuild; -} - -function addTableField() { - var fieldList = $('fieldlist'); - var toCopy = $E('.fieldbox', fieldList).innerHTML; - - if (f(toCopy)) { - var newField = new Element('div'); - newField.set('html', toCopy); - newField.className = "fieldbox"; - fieldList.appendChild(newField); - - clearForm(newField); - - var valueLine = $E(".valueline", newField); - if (f(valueLine)) - valueLine.style.display = 'none'; - - if (!Browser.Engine.trident) { - var newHeader = $E(".fieldheader", newField).childNodes[1]; - newHeader.set('html', '<' + gettext("New field") + '>'); - } - - } - sizePage(); -} - -function clearForm(elem) { - var inputs = elem.getElementsByTagName("input"); - for (var i=0; i 0) { - - $('TABLENAME').style.border = ""; - - if (adapter == "sqlite") { - var createQuery = "CREATE TABLE " + tableName + " ("; - } else { - var createQuery = "CREATE TABLE `" + tableName + "` ("; - } - - for (var i=0; i= 0 || obj.value.indexOf("text") >= 0 || obj.value == "enum" || obj.value == "set") { - charsetToggle[0].style.display = ''; - charsetToggle[1].style.display = ''; - } else { - charsetToggle[0].style.display = 'none'; - charsetToggle[1].style.display = 'none'; - } - } - - sizePage(); -} - -function exportFilePrep() { - var oft = $('OUTPUTFILETEXT'); - if ($('OUTPUTFILE').checked) { - - defaultFilename = gettext("Export").toLowerCase(); - - if ($('SQLTOGGLE').checked) { - if (oft.value == "" || oft.value == defaultFilename + ".csv") - oft.value = defaultFilename + ".sql"; - oft.focus(); - } else { - if (oft.value == "" || oft.value == defaultFilename + ".sql") - oft.value = defaultFilename + ".csv"; - oft.focus(); - } - } -} - -function startImport() { - $('importLoad').style.display = ''; - $('importForm').setAttribute("target", "importFrame"); -} - -function updateAfterImport(message) { - $('importLoad').style.display = 'none'; - $('importMessage').style.display = ''; - $('importMessage').innerHTML = message; - clearPanesOnLoad = true; -} - -function paneCheckAll(elemId) { - var elem = $(elemId); - var inputs = elem.getElementsByTagName("input"); - for (var i=0; i 0) { - win.style.opacity = opacities.pop(); - var nextWin = function(){ closeWindowCallback(winId, speed, opacities); }; - nextWin.delay(speed); - } else { - win.dispose(); - } -} - -function switchLanguage() { - var langSelect = $('langSwitcher'); - var lang = langSelect.options[langSelect.selectedIndex].value; - var defaultLang = "en_US"; - - if (lang != defaultLang) { - var co = Cookie.write("sb_lang", lang, {duration: 60}); - } else if (Cookie.read("sb_lang")) { - Cookie.dispose("sb_lang"); - } - location.reload(true); -} - -function switchTheme() { - var themeSelect = $('themeSwitcher'); - var theme = themeSelect.options[themeSelect.selectedIndex].value; - var defaultTheme = "bittersweet"; - - if (theme != defaultTheme) { - var co = Cookie.write("sb_theme", theme, {duration: 60}); - } else if (Cookie.read("sb_theme")) { - Cookie.dispose("sb_theme"); - } - location.reload(true); -} - -function quoteModifier(mod) { - return returnQuote() + mod + returnQuote(); -} - -function returnQuote() { - if (adapter == "sqlite") { - return "'"; - } else if (adapter == "mysql") { - return "`"; - } -} - -function autoExpandTextareas() { - var taList = document.getElementsByTagName("textarea"); - if (taList.length > 0 && sb.page != "export.php") { - var sizeDiv = new Element('div'); - sizeDiv.id = "sizeDiv"; - sizeDiv.style.visibility = "hidden"; - sizeDiv.style.position = "absolute"; - sizeDiv.style.lineHeight = "15px"; - sizeDiv.style.fontSize = "13px"; - sizeDiv.style.padding = "2px"; - document.body.appendChild(sizeDiv); - - for (var i=0; i') + ' '); - - var newHeight = theDiv.clientHeight + 5; - - if (newHeight < 80) { - newHeight = 80; - } else if (newHeight > 300) { - newHeight = 300; - } - - taList[i].style.height = newHeight + "px"; - } - - document.body.removeChild(sizeDiv); - } -} - -function yellowFade(el, curr) { - if (!curr) - curr = 175; - - el.style.background = 'rgb(255, 255, '+ (curr+=3) +')'; - - if (curr < 255) - setTimeout(function(){ yellowFade(el, curr) }, 25); +function clearPanes() { + $('innercontent').empty(); +} + +function toggleMenuClick(e) { + var event = new Event(e); + var menuId = event.target.parentNode.parentNode.id; + toggleMenu(menuId.substring(2)); +} + +function toggleMenu(b, forceExpand) { + b = parseInt(b); + var menuId = "db" + b; + var menu = $(menuId); + var sub = "sublist" + b; + + if (!menu.hasClass("expanded")) { + // accordion + var openMenus = $ES(".expanded"); + for (var m=0; m= 0 && lastActiveRow != rowId) { + if (context) { + var grid = $E('.gridscroll', $(context)); + var checks = $E('.leftchecks', $(context)).childNodes; + } else { + var grid = sb.grid; + var checks = sb.leftChecks.childNodes; + } + + if (rowId < lastActiveRow) { + for (var i=rowId+1; ilastActiveRow; i--) { + checks[i].firstChild.firstChild.checked = checks[rowId].firstChild.firstChild.checked; + highlightDataRow(i, context); + } + } + } + lastActiveRow = rowId; +} + +function highlightDataRow(i, context) { + if (context) { + var grid = $(context); + var rows = $E('.gridscroll', grid).childNodes; + var lc = $E('.leftchecks', grid).childNodes; + } else { + var rows = sb.grid.childNodes; + var lc = sb.leftChecks.childNodes; + } + + if (lc[i].firstChild.firstChild.checked == true) { + if (rows[i].className.indexOf("highlighted") == -1) { + rows[i].className += " highlighted"; + lc[i].className += " highlighted"; + } + } else { + if (rows[i].className.indexOf("highlighted") != -1) { + rows[i].className = rows[i].className.replace("highlighted", ""); + lc[i].className = lc[i].className.replace("highlighted", ""); + } + } +} + +function editSelectedRows() { + var grid = sb.grid; + if (f(grid)) { + var editParts = ""; + var count = 0; + var inputs = $ES("input", sb.leftChecks); + for (var i=0; i 0) { + if (sb.page == "structure.php") + var loadPage = "editcolumn.php"; + else if (sb.page == "users.php") + var loadPage = "edituser.php"; + else + var loadPage = "edit.php"; + + editParts = editParts.substring(0, editParts.length - 2); + sb.topTabs[sb.topTabSet].addTab("Edit", loadPage, true); + sb.page = loadPage; + var x = new XHR({url: loadPage, onSuccess: finishTabLoad}).send("editParts=" + editParts); + } + } +} + +function saveEdit(formId) { + var form = $(formId); + var queryPart = form.get("querypart"); + var x = new XHR({url: "ajaxsaveedit.php?queryPart=" + queryPart + "&form=" + formId, onSuccess: updateAfterEdit}).send(form.toQueryString()); +} + +function saveColumnEdit(formId) { + var form = $(formId); + var changes = getFieldSummary(form); + var columnQuery = "ALTER TABLE `" + sb.table + "` CHANGE `" + form.get("querypart") + "` " + changes; + var x = new XHR({url: "ajaxsavecolumnedit.php?form=" + formId, onSuccess: updateAfterEdit}).send("runQuery=" + columnQuery); +} + +function saveUserEdit(formId) { + var form = $(formId); + var x = new XHR({url: "ajaxsaveuseredit.php?form=" + formId + "&user=" + form.get("querypart"), onSuccess: updateAfterEdit}).send(form.toQueryString()); +} + +function updateAfterEdit(json) { + var response = eval('(' + json + ')'); + var formu = $(response.formupdate); + if (response.errormess == "") { + showUpdateMessage(formu); + } else { + var errHandle = $E('.errormessage', formu); + errHandle.style.display = ''; + errHandle.set('text', response.errormess); + } + sizePage(); + clearPanesOnLoad = true; +} + +function showUpdateMessage(formu) { + // hide other messages + hideUpdateMessages(); + + formu.innerHTML = ""; + var updateId = sb.$GUID++; + var updateDiv = new Element("div", { + 'class': 'insertmessage', + 'id': 'update' + updateId + }).set('text', gettext("Your changes were saved to the database.")); + formu.appendChild(updateDiv); + yellowFade($('update' + updateId)); + setTimeout(hideUpdateMessages, 1250); +} + +function hideUpdateMessages() { + var updates = $ES(".insertmessage"); + var edits = $ES(".edit"); + + if (edits.length == 0) { + updates[0].set('text', gettext("Redirecting...")); + + for (var i=1; i" + emptyQuery + "", + "var x = new XHR({url: \"ajaxquery.php\", onSuccess: emptyTableCallback}).send(\"query=" + encodeURIComponent(emptyQuery) + "&silent=1\")" + ); + } +} + +function emptyTableCallback() { + sb.tableRowCounts[sb.db + "_" + sb.table] = "0"; + subTabLoad(sb.db, sb.table); +} + +function confirmDropTable() { + var table = sb.table; + if (f(table)) { + var dropQuery = "DROP TABLE " + returnQuote() + table + returnQuote(); + var targ = $(getSubMenuId(sb.db, sb.table)); + while (!targ.hasClass("sublist")) { + targ = targ.parentNode; + } + var toRecalculate = targ.id; + showDialog(gettext("Confirm"), + printf(gettext("Are you sure you want to drop the '%s' table? This will delete the table and all data inside of it. The following query will be run:"), table) + "
      " + dropQuery + "
      ", + "var x = new XHR({url: \"ajaxquery.php\"}).send(\"query=" + dropQuery + "&silent=1\"); $(getSubMenuId(sb.db, sb.table)).dispose(); databaseLoad(sb.db); recalculateSubmenuHeight(\"" + toRecalculate + "\");" + ); + } +} + +function optimizeTable() { + if (sb.table) { + var optimizeQuery = "OPTIMIZE TABLE `" + sb.table + "`;"; + var x = new XHR({url: "ajaxquery.php", onSuccess: function(){ sb.loadPage() } }).send("query=" + optimizeQuery + "&silent=1"); + } +} + +function confirmDropDatabase() { + var db = sb.db; + if (f(db)) { + var dropQuery = "DROP DATABASE `" + db + "`"; + showDialog(gettext("Confirm"), + printf(gettext("Are you sure you want to drop the database '%s'? This will delete the database, the tables inside the database, and all data inside of the tables. The following query will be run:"), db) + "
      " + dropQuery + "
      ", + "var x = new XHR({url: \"ajaxquery.php\"}).send(\"query=" + dropQuery + "&silent=1\"); $(getSubMenuId(sb.db, sb.table)).dispose(); sideMainClick(\"home.php\",\"hometab\");" + ); + } +} + +function editTable() { + var newName = $('RENAME').value; + var charSelect = $('RECHARSET'); + if (charSelect) + var newCharset = charSelect.options[charSelect.selectedIndex].value; + + var runQuery = ""; + + if (newName != sb.table && adapter == "mysql") { + runQuery += "RENAME TABLE `" + sb.table + "` TO `" + newName + "`;"; + } else if (newName != sb.table && adapter == "sqlite") { + runQuery += "ALTER TABLE '" + sb.table + "' RENAME TO '" + newName + "';"; + } + + if (f(newCharset) != "") { + runQuery += "ALTER TABLE `" + sb.table + "` CHARSET " + newCharset + ";"; + } + + if (f(runQuery) != "") { + $('RENAME').blur(); + var x = new XHR({url: "ajaxquery.php", onSuccess: editTableCallback}).send("query=" + runQuery + "&silent=1"); + } + + // defined interally on purpose + function editTableCallback() { + if (f(newName) != "" && newName != sb.table) { + var submenuItem = $(sb.submenuIds[sb.db + '_' + sb.table]); + submenuItem.firstChild.set('text', newName); + submenuItem.firstChild.href = "#page=browse&db=" + sb.db + "&table=" + newName + "&topTabSet=2"; + var subacount = new Element('span'); + subacount.className = "subcount"; + subacount.appendText("(" + approximateNumber(sb.tableRowCounts[sb.db + '_' + sb.table]) + ")"); + submenuItem.firstChild.appendChild(subacount); + + sb.submenuIds[sb.db + '_' + newName] = sb.submenuIds[sb.db + '_' + sb.table]; + sb.submenuIds[sb.db + '_' + sb.table] = ''; + sb.tableRowCounts[sb.db + '_' + newName] = sb.tableRowCounts[sb.db + '_' + sb.table]; + sb.tableRowCounts[sb.db + '_' + sb.table] = ''; + sb.table = newName; + sb.setHash(); + } + + $('editTableMessage').set('text', gettext("Successfully saved changes.")); + yellowFade($('editTableMessage')); + var clearTable = function() { + $('editTableMessage').empty(); + }; + + clearTable.delay(2000); + + clearPanesOnLoad = true; + } +} + +function editDatabase() { + var charSelect = $('DBRECHARSET'); + var newCharset = charSelect.options[charSelect.selectedIndex].value; + + if (f(newCharset) != "") { + var runQuery = "ALTER DATABASE `" + sb.db + "` CHARSET " + newCharset + ";"; + var x = new XHR({url: "ajaxquery.php", onSuccess: editDatabaseCallback}).send("query=" + runQuery + "&silent=1"); + } + + function editDatabaseCallback() { + $('editDatabaseMessage').set('text', gettext("Successfully saved changes.")); + yellowFade($('editDatabaseMessage')); + + var clearDatabase = function() { + $('editDatabaseMessage').empty(); + }; + + clearDatabase.delay(2000); + + clearPanesOnLoad = true; + } +} + +function runJavascriptContent() { + var scripts = $ES("script", sb.pane); + for (var i=0; i 0) { + for (var i=0; i" + name + ""; + else if (adapter == "sqlite") + fieldBuild = name; + else + fieldBuild = "`" + name + "`"; + + if (adapter == "sqlite") { + if (f(type)) + fieldBuild += " " + type; + if (f(size) && f(type)) + fieldBuild += "(" + size + ")"; + if (f(notnull)) + fieldBuild += " not null"; + if (f(key)) + fieldBuild += " " + key + " key"; + if (f(auto)) + fieldBuild += " autoincrement"; + if (f(unique)) + fieldBuild += " unique"; + if (f(defaultval)) + fieldBuild += " default '" + defaultval + "'"; + } else { + if (f(type)) + fieldBuild += " " + type; + if (f(values) && (type == "set" || type == "enum")) + fieldBuild += values + ""; + if (f(size) && f(type)) + fieldBuild += "(" + size + ")"; + if (f(unsign)) + fieldBuild += " unsigned"; + if (f(binary)) + fieldBuild += " binary"; + if (f(charset)) + fieldBuild += " charset " + charset; + if (f(notnull)) + fieldBuild += " not null"; + if (f(defaultval)) + fieldBuild += " default '" + defaultval + "'"; + if (f(auto)) + fieldBuild += " auto_increment"; + if (f(key)) + fieldBuild += " " + key + " key"; + } + + } + } + return fieldBuild; +} + +function addTableField() { + var fieldList = $('fieldlist'); + var toCopy = $E('.fieldbox', fieldList).innerHTML; + + if (f(toCopy)) { + var newField = new Element('div'); + newField.set('html', toCopy); + newField.className = "fieldbox"; + fieldList.appendChild(newField); + + clearForm(newField); + + var valueLine = $E(".valueline", newField); + if (f(valueLine)) + valueLine.style.display = 'none'; + + if (!Browser.Engine.trident) { + var newHeader = $E(".fieldheader", newField).childNodes[1]; + newHeader.set('html', '<' + gettext("New field") + '>'); + } + + } + sizePage(); +} + +function clearForm(elem) { + var inputs = elem.getElementsByTagName("input"); + for (var i=0; i 0) { + + $('TABLENAME').style.border = ""; + + if (adapter == "sqlite") { + var createQuery = "CREATE TABLE " + tableName + " ("; + } else { + var createQuery = "CREATE TABLE `" + tableName + "` ("; + } + + for (var i=0; i= 0 || obj.value.indexOf("text") >= 0 || obj.value == "enum" || obj.value == "set") { + charsetToggle[0].style.display = ''; + charsetToggle[1].style.display = ''; + } else { + charsetToggle[0].style.display = 'none'; + charsetToggle[1].style.display = 'none'; + } + } + + sizePage(); +} + +function exportFilePrep() { + var oft = $('OUTPUTFILETEXT'); + if ($('OUTPUTFILE').checked) { + + defaultFilename = gettext("Export").toLowerCase(); + + if ($('SQLTOGGLE').checked) { + if (oft.value == "" || oft.value == defaultFilename + ".csv") + oft.value = defaultFilename + ".sql"; + oft.focus(); + } else { + if (oft.value == "" || oft.value == defaultFilename + ".sql") + oft.value = defaultFilename + ".csv"; + oft.focus(); + } + } +} + +function startImport() { + $('importLoad').style.display = ''; + $('importForm').setAttribute("target", "importFrame"); +} + +function updateAfterImport(message) { + $('importLoad').style.display = 'none'; + $('importMessage').style.display = ''; + $('importMessage').innerHTML = message; + clearPanesOnLoad = true; +} + +function paneCheckAll(elemId) { + var elem = $(elemId); + var inputs = elem.getElementsByTagName("input"); + for (var i=0; i 0) { + win.style.opacity = opacities.pop(); + var nextWin = function(){ closeWindowCallback(winId, speed, opacities); }; + nextWin.delay(speed); + } else { + win.dispose(); + } +} + +function switchLanguage() { + var langSelect = $('langSwitcher'); + var lang = langSelect.options[langSelect.selectedIndex].value; + var defaultLang = "en_US"; + + if (lang != defaultLang) { + var co = Cookie.write("sb_lang", lang, {duration: 60}); + } else if (Cookie.read("sb_lang")) { + Cookie.dispose("sb_lang"); + } + location.reload(true); +} + +function switchTheme() { + var themeSelect = $('themeSwitcher'); + var theme = themeSelect.options[themeSelect.selectedIndex].value; + var defaultTheme = "bittersweet"; + + if (theme != defaultTheme) { + var co = Cookie.write("sb_theme", theme, {duration: 60}); + } else if (Cookie.read("sb_theme")) { + Cookie.dispose("sb_theme"); + } + location.reload(true); +} + +function quoteModifier(mod) { + return returnQuote() + mod + returnQuote(); +} + +function returnQuote() { + if (adapter == "sqlite") { + return "'"; + } else if (adapter == "mysql") { + return "`"; + } +} + +function autoExpandTextareas() { + var taList = document.getElementsByTagName("textarea"); + if (taList.length > 0 && sb.page != "export.php") { + var sizeDiv = new Element('div'); + sizeDiv.id = "sizeDiv"; + sizeDiv.style.visibility = "hidden"; + sizeDiv.style.position = "absolute"; + sizeDiv.style.lineHeight = "15px"; + sizeDiv.style.fontSize = "13px"; + sizeDiv.style.padding = "2px"; + document.body.appendChild(sizeDiv); + + for (var i=0; i') + ' '); + + var newHeight = theDiv.clientHeight + 5; + + if (newHeight < 80) { + newHeight = 80; + } else if (newHeight > 300) { + newHeight = 300; + } + + taList[i].style.height = newHeight + "px"; + } + + document.body.removeChild(sizeDiv); + } +} + +function yellowFade(el, curr) { + if (!curr) + curr = 175; + + el.style.background = 'rgb(255, 255, '+ (curr+=3) +')'; + + if (curr < 255) + setTimeout(function(){ yellowFade(el, curr) }, 25); } \ No newline at end of file diff --git a/htdocs/sqlbuddy/js/mootools-1.2-core.js b/htdocs/sqlbuddy/js/mootools-1.2-core.js index da8b02170..ee90d355c 100755 --- a/htdocs/sqlbuddy/js/mootools-1.2-core.js +++ b/htdocs/sqlbuddy/js/mootools-1.2-core.js @@ -1,242 +1,242 @@ -//MooTools, , My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2008 Valerio Proietti, , MIT Style License. - -var MooTools={version:"1.2.0",build:""};var Native=function(J){J=J||{};var F=J.afterImplement||function(){};var G=J.generics;G=(G!==false);var H=J.legacy; -var E=J.initialize;var B=J.protect;var A=J.name;var C=E||H;C.constructor=Native;C.$family={name:"native"};if(H&&E){C.prototype=H.prototype;}C.prototype.constructor=C; -if(A){var D=A.toLowerCase();C.prototype.$family={name:D};Native.typize(C,D);}var I=function(M,K,N,L){if(!B||L||!M.prototype[K]){M.prototype[K]=N;}if(G){Native.genericize(M,K,B); -}F.call(M,K,N);return M;};C.implement=function(L,K,N){if(typeof L=="string"){return I(this,L,K,N);}for(var M in L){I(this,M,L[M],K);}return this;};C.alias=function(M,K,N){if(typeof M=="string"){M=this.prototype[M]; -if(M){I(this,K,M,N);}}else{for(var L in M){this.alias(L,M[L],K);}}return this;};return C;};Native.implement=function(D,C){for(var B=0,A=D.length;B-1:this.indexOf(A)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,"");},clean:function(){return this.replace(/\s+/g," ").trim(); -},camelCase:function(){return this.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(A){return("-"+A.charAt(0).toLowerCase()); -});},capitalize:function(){return this.replace(/\b[a-z]/g,function(A){return A.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1"); -},toInt:function(A){return parseInt(this,A||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(B){var A=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); -return(A)?A.slice(1).hexToRgb(B):null;},rgbToHex:function(B){var A=this.match(/\d{1,3}/g);return(A)?A.rgbToHex(B):null;},stripScripts:function(B){var A=""; -var C=this.replace(/]*>([\s\S]*?)<\/script>/gi,function(){A+=arguments[1]+"\n";return"";});if(B===true){$exec(A);}else{if($type(B)=="function"){B(A,C); -}}return C;},substitute:function(A,B){return this.replace(B||(/\\?\{([^}]+)\}/g),function(D,C){if(D.charAt(0)=="\\"){return D.slice(1);}return(A[C]!=undefined)?A[C]:""; -});}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(B){for(var A in this){if(this.hasOwnProperty(A)&&this[A]===B){return A;}}return null; -},hasValue:function(A){return(Hash.keyOf(this,A)!==null);},extend:function(A){Hash.each(A,function(C,B){Hash.set(this,B,C);},this);return this;},combine:function(A){Hash.each(A,function(C,B){Hash.include(this,B,C); -},this);return this;},erase:function(A){if(this.hasOwnProperty(A)){delete this[A];}return this;},get:function(A){return(this.hasOwnProperty(A))?this[A]:null; -},set:function(A,B){if(!this[A]||this.hasOwnProperty(A)){this[A]=B;}return this;},empty:function(){Hash.each(this,function(B,A){delete this[A];},this); -return this;},include:function(B,C){var A=this[B];if(A==undefined){this[B]=C;}return this;},map:function(B,C){var A=new Hash;Hash.each(this,function(E,D){A.set(D,B.call(C,E,D,this)); -},this);return A;},filter:function(B,C){var A=new Hash;Hash.each(this,function(E,D){if(B.call(C,E,D,this)){A.set(D,E);}},this);return A;},every:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&!B.call(C,this[A],A)){return false; -}}return true;},some:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&B.call(C,this[A],A)){return true;}}return false;},getKeys:function(){var A=[]; -Hash.each(this,function(C,B){A.push(B);});return A;},getValues:function(){var A=[];Hash.each(this,function(B){A.push(B);});return A;},toQueryString:function(A){var B=[]; -Hash.each(this,function(F,E){if(A){E=A+"["+E+"]";}var D;switch($type(F)){case"object":D=Hash.toQueryString(F,E);break;case"array":var C={};F.each(function(H,G){C[G]=H; -});D=Hash.toQueryString(C,E);break;default:D=E+"="+encodeURIComponent(F);}if(F!=undefined){B.push(D);}});return B.join("&");}});Hash.alias({keyOf:"indexOf",hasValue:"contains"}); -var Event=new Native({name:"Event",initialize:function(A,F){F=F||window;var K=F.document;A=A||F.event;if(A.$extended){return A;}this.$extended=true;var J=A.type; -var G=A.target||A.srcElement;while(G&&G.nodeType==3){G=G.parentNode;}if(J.test(/key/)){var B=A.which||A.keyCode;var M=Event.Keys.keyOf(B);if(J=="keydown"){var D=B-111; -if(D>0&&D<13){M="f"+D;}}M=M||String.fromCharCode(B).toLowerCase();}else{if(J.match(/(click|mouse|menu)/i)){K=(!K.compatMode||K.compatMode=="CSS1Compat")?K.html:K.body; -var I={x:A.pageX||A.clientX+K.scrollLeft,y:A.pageY||A.clientY+K.scrollTop};var C={x:(A.pageX)?A.pageX-F.pageXOffset:A.clientX,y:(A.pageY)?A.pageY-F.pageYOffset:A.clientY}; -if(J.match(/DOMMouseScroll|mousewheel/)){var H=(A.wheelDelta)?A.wheelDelta/120:-(A.detail||0)/3;}var E=(A.which==3)||(A.button==2);var L=null;if(J.match(/over|out/)){switch(J){case"mouseover":L=A.relatedTarget||A.fromElement; -break;case"mouseout":L=A.relatedTarget||A.toElement;}if(!(function(){while(L&&L.nodeType==3){L=L.parentNode;}return true;}).create({attempt:Browser.Engine.gecko})()){L=false; -}}}}return $extend(this,{event:A,type:J,page:I,client:C,rightClick:E,wheel:H,relatedTarget:L,target:G,code:B,key:M,shift:A.shiftKey,control:A.ctrlKey,alt:A.altKey,meta:A.metaKey}); -}});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault(); -},stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault(); -}else{this.event.returnValue=false;}return this;}});var Class=new Native({name:"Class",initialize:function(B){B=B||{};var A=function(E){for(var D in this){this[D]=$unlink(this[D]); -}for(var F in Class.Mutators){if(!this[F]){continue;}Class.Mutators[F](this,this[F]);delete this[F];}this.constructor=A;if(E===$empty){return this;}var C=(this.initialize)?this.initialize.apply(this,arguments):this; -if(this.options&&this.options.initialize){this.options.initialize.call(this);}return C;};$extend(A,this);A.constructor=Class;A.prototype=B;return A;}}); -Class.implement({implement:function(){Class.Mutators.Implements(this.prototype,Array.slice(arguments));return this;}});Class.Mutators={Implements:function(A,B){$splat(B).each(function(C){$extend(A,($type(C)=="class")?new C($empty):C); -});},Extends:function(self,klass){var instance=new klass($empty);delete instance.parent;delete instance.parentOf;for(var key in instance){var current=self[key],previous=instance[key]; -if(current==undefined){self[key]=previous;continue;}var ctype=$type(current),ptype=$type(previous);if(ctype!=ptype){continue;}switch(ctype){case"function":if(!arguments.callee.caller){self[key]=eval("("+String(current).replace(/\bthis\.parent\(\s*(\))?/g,function(full,close){return"arguments.callee._parent_.call(this"+(close||", "); -})+")");}self[key]._parent_=previous;break;case"object":self[key]=$merge(previous,current);}}self.parent=function(){return arguments.callee.caller._parent_.apply(this,arguments); -};self.parentOf=function(descendant){return descendant._parent_.apply(this,Array.slice(arguments,1));};}};var Chain=new Class({chain:function(){this.$chain=(this.$chain||[]).extend(arguments); -return this;},callChain:function(){return(this.$chain&&this.$chain.length)?this.$chain.shift().apply(this,arguments):false;},clearChain:function(){if(this.$chain){this.$chain.empty(); -}return this;}});var Events=new Class({addEvent:function(C,B,A){C=Events.removeOn(C);if(B!=$empty){this.$events=this.$events||{};this.$events[C]=this.$events[C]||[]; -this.$events[C].include(B);if(A){B.internal=true;}}return this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;},fireEvent:function(C,B,A){C=Events.removeOn(C); -if(!this.$events||!this.$events[C]){return this;}this.$events[C].each(function(D){D.create({bind:this,delay:A,"arguments":B})();},this);return this;},removeEvent:function(B,A){B=Events.removeOn(B); -if(!this.$events||!this.$events[B]){return this;}if(!A.internal){this.$events[B].erase(A);}return this;},removeEvents:function(C){for(var D in this.$events){if(C&&C!=D){continue; -}var B=this.$events[D];for(var A=B.length;A--;A){this.removeEvent(D,B[A]);}}return this;}});Events.removeOn=function(A){return A.replace(/^on([A-Z])/,function(B,C){return C.toLowerCase(); -});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent){return this;}for(var A in this.options){if($type(this.options[A])!="function"||!(/^on[A-Z]/).test(A)){continue; -}this.addEvent(A,this.options[A]);delete this.options[A];}return this;}});Document.implement({newElement:function(A,B){if(Browser.Engine.trident&&B){["name","type","checked"].each(function(C){if(!B[C]){return ; -}A+=" "+C+'="'+B[C]+'"';if(C!="checked"){delete B[C];}});A="<"+A+">";}return $.element(this.createElement(A)).set(B);},newTextNode:function(A){return this.createTextNode(A); -},getDocument:function(){return this;},getWindow:function(){return this.defaultView||this.parentWindow;},purge:function(){var C=this.getElementsByTagName("*"); -for(var B=0,A=C.length;B1);A.each(function(E){var F=this.getElementsByTagName(E.trim());(B)?C.extend(F):C=F;},this);return new Elements(C,{ddup:B,cash:!D}); -}});Element.Storage={get:function(A){return(this[A]||(this[A]={}));}};Element.Inserters=new Hash({before:function(B,A){if(A.parentNode){A.parentNode.insertBefore(B,A); -}},after:function(B,A){if(!A.parentNode){return ;}var C=A.nextSibling;(C)?A.parentNode.insertBefore(B,C):A.parentNode.appendChild(B);},bottom:function(B,A){A.appendChild(B); -},top:function(B,A){var C=A.firstChild;(C)?A.insertBefore(B,C):A.appendChild(B);}});Element.Inserters.inside=Element.Inserters.bottom;Element.Inserters.each(function(C,B){var A=B.capitalize(); -Element.implement("inject"+A,function(D){C(this,$(D,true));return this;});Element.implement("grab"+A,function(D){C($(D,true),this);return this;});});Element.implement({getDocument:function(){return this.ownerDocument; -},getWindow:function(){return this.ownerDocument.getWindow();},getElementById:function(D,C){var B=this.ownerDocument.getElementById(D);if(!B){return null; -}for(var A=B.parentNode;A!=this;A=A.parentNode){if(!A){return null;}}return $.element(B,C);},set:function(D,B){switch($type(D)){case"object":for(var C in D){this.set(C,D[C]); -}break;case"string":var A=Element.Properties.get(D);(A&&A.set)?A.set.apply(this,Array.slice(arguments,1)):this.setProperty(D,B);}return this;},get:function(B){var A=Element.Properties.get(B); -return(A&&A.get)?A.get.apply(this,Array.slice(arguments,1)):this.getProperty(B);},erase:function(B){var A=Element.Properties.get(B);(A&&A.erase)?A.erase.apply(this,Array.slice(arguments,1)):this.removeProperty(B); -return this;},match:function(A){return(!A||Element.get(this,"tag")==A);},inject:function(B,A){Element.Inserters.get(A||"bottom")(this,$(B,true));return this; -},wraps:function(B,A){B=$(B,true);return this.replaces(B).grab(B,A);},grab:function(B,A){Element.Inserters.get(A||"bottom")($(B,true),this);return this; -},appendText:function(B,A){return this.grab(this.getDocument().newTextNode(B),A);},adopt:function(){Array.flatten(arguments).each(function(A){A=$(A,true); -if(A){this.appendChild(A);}},this);return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this;},clone:function(D,C){switch($type(this)){case"element":var H={}; -for(var G=0,E=this.attributes.length;G1),cash:!G});}});Element.implement({match:function(B){if(!B){return true; -}var D=Selectors.Utils.parseTagAndID(B);var A=D[0],E=D[1];if(!Selectors.Filters.byID(this,E)||!Selectors.Filters.byTag(this,A)){return false;}var C=Selectors.Utils.parseSelector(B); -return(C)?Selectors.Utils.filter(this,C,{}):true;}});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)["']?(.*?)["']?)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)}; -Selectors.Utils={chk:function(B,C){if(!C){return true;}var A=$uid(B);if(!C[A]){return C[A]=true;}return false;},parseNthArgument:function(F){if(Selectors.Cache.nth[F]){return Selectors.Cache.nth[F]; -}var C=F.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!C){return false;}var E=parseInt(C[1]);var B=(E||E===0)?E:1;var D=C[2]||false;var A=parseInt(C[3])||0; -if(B!=0){A--;while(A<1){A+=B;}while(A>=B){A-=B;}}else{B=A;D="index";}switch(D){case"n":C={a:B,b:A,special:"n"};break;case"odd":C={a:2,b:0,special:"n"}; -break;case"even":C={a:2,b:1,special:"n"};break;case"first":C={a:0,special:"index"};break;case"last":C={special:"last-child"};break;case"only":C={special:"only-child"}; -break;default:C={a:(B-1),special:"index"};}return Selectors.Cache.nth[F]=C;},parseSelector:function(E){if(Selectors.Cache.parsed[E]){return Selectors.Cache.parsed[E]; -}var D,H={classes:[],pseudos:[],attributes:[]};while((D=Selectors.RegExps.combined.exec(E))){var I=D[1],G=D[2],F=D[3],B=D[4],C=D[5],J=D[6];if(I){H.classes.push(I); -}else{if(C){var A=Selectors.Pseudo.get(C);if(A){H.pseudos.push({parser:A,argument:J});}else{H.attributes.push({name:C,operator:"=",value:J});}}else{if(G){H.attributes.push({name:G,operator:F,value:B}); -}}}}if(!H.classes.length){delete H.classes;}if(!H.attributes.length){delete H.attributes;}if(!H.pseudos.length){delete H.pseudos;}if(!H.classes&&!H.attributes&&!H.pseudos){H=null; -}return Selectors.Cache.parsed[E]=H;},parseTagAndID:function(B){var A=B.match(Selectors.RegExps.tag);var C=B.match(Selectors.RegExps.id);return[(A)?A[1]:"*",(C)?C[1]:false]; -},filter:function(F,C,E){var D;if(C.classes){for(D=C.classes.length;D--;D){var G=C.classes[D];if(!Selectors.Filters.byClass(F,G)){return false;}}}if(C.attributes){for(D=C.attributes.length; -D--;D){var B=C.attributes[D];if(!Selectors.Filters.byAttribute(F,B.name,B.operator,B.value)){return false;}}}if(C.pseudos){for(D=C.pseudos.length;D--;D){var A=C.pseudos[D]; -if(!Selectors.Filters.byPseudo(F,A.parser,A.argument,E)){return false;}}}return true;},getByTagAndID:function(B,A,D){if(D){var C=(B.getElementById)?B.getElementById(D,true):Element.getElementById(B,D,true); -return(C&&Selectors.Filters.byTag(C,A))?[C]:[];}else{return B.getElementsByTagName(A);}},search:function(J,I,O){var B=[];var C=I.trim().replace(Selectors.RegExps.splitter,function(Z,Y,X){B.push(Y); -return":)"+X;}).split(":)");var K,F,E,V;for(var U=0,Q=C.length;U":function(H,G,I,A,F){var C=Selectors.Utils.getByTagAndID(G,I,A);for(var E=0,D=C.length;EA){return false; -}}return(C==A);},even:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n+1",A);},odd:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n",A); -}});Element.Events.domready={onAdd:function(A){if(Browser.loaded){A.call(this);}}};(function(){var B=function(){if(Browser.loaded){return ;}Browser.loaded=true; -window.fireEvent("domready");document.fireEvent("domready");};switch(Browser.Engine.name){case"webkit":(function(){(["loaded","complete"].contains(document.readyState))?B():arguments.callee.delay(50); -})();break;case"trident":var A=document.createElement("div");(function(){($try(function(){A.doScroll("left");return $(A).inject(document.body).set("html","temp").dispose(); -}))?B():arguments.callee.delay(50);})();break;default:window.addEvent("load",B);document.addEvent("DOMContentLoaded",B);}})();var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(B,A){this.key=B; -this.setOptions(A);},write:function(B){B=encodeURIComponent(B);if(this.options.domain){B+="; domain="+this.options.domain;}if(this.options.path){B+="; path="+this.options.path; -}if(this.options.duration){var A=new Date();A.setTime(A.getTime()+this.options.duration*24*60*60*1000);B+="; expires="+A.toGMTString();}if(this.options.secure){B+="; secure"; -}this.options.document.cookie=this.key+"="+B;return this;},read:function(){var A=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)"); -return(A)?decodeURIComponent(A[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(B,C,A){return new Cookie(B,A).write(C); -};Cookie.read=function(A){return new Cookie(A).read();};Cookie.dispose=function(B,A){return new Cookie(B,A).dispose();};var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},initialize:function(A){this.xhr=new Browser.Request(); -this.setOptions(A);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return ; -}this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML}; -this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300)); -},processScripts:function(A){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(A);}return A.stripScripts(this.options.evalScripts); -},success:function(B,A){this.onSuccess(this.processScripts(B),A);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain(); -},failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(A,B){this.headers.set(A,B); -return this;},getHeader:function(A){return $try(function(){return this.xhr.getResponseHeader(A);}.bind(this));},check:function(A){if(!this.running){return true; -}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(A.bind(this,Array.slice(arguments,1)));return false;}return false; -},send:function(I){if(!this.check(arguments.callee,I)){return this;}this.running=true;var G=$type(I);if(G=="string"||G=="element"){I={data:I};}var D=this.options; -I=$extend({data:D.data,url:D.url,method:D.method},I);var E=I.data,B=I.url,A=I.method;switch($type(E)){case"element":E=$(E).toQueryString();break;case"object":case"hash":E=Hash.toQueryString(E); -}if(this.options.format){var H="format="+this.options.format;E=(E)?H+"&"+E:H;}if(this.options.emulation&&["put","delete"].contains(A)){var F="_method="+A; -E=(E)?F+"&"+E:F;A="post";}if(this.options.urlEncoded&&A=="post"){var C=(this.options.encoding)?"; charset="+this.options.encoding:"";this.headers.set("Content-type","application/x-www-form-urlencoded"+C); -}if(E&&A=="get"){B=B+(B.contains("?")?"&":"?")+E;E=null;}this.xhr.open(A.toUpperCase(),B,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this); -this.headers.each(function(K,J){if(!$try(function(){this.xhr.setRequestHeader(J,K);return true;}.bind(this))){this.fireEvent("exception",[J,K]);}},this); -this.fireEvent("request");this.xhr.send(E);if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this; -}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var A={}; -["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(B){A[B]=function(){var C=Array.link(arguments,{url:String.type,data:$defined}); -return this.send($extend(C,{method:B.toLowerCase()}));};});Request.implement(A);})();Element.Properties.send={set:function(A){var B=this.retrieve("send"); -if(B){B.cancel();}return this.eliminate("send").store("send:options",$extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},A)); -},get:function(A){if(A||!this.retrieve("send")){if(A||!this.retrieve("send:options")){this.set("send",A);}this.store("send",new Request(this.retrieve("send:options"))); +//MooTools, , My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2008 Valerio Proietti, , MIT Style License. + +var MooTools={version:"1.2.0",build:""};var Native=function(J){J=J||{};var F=J.afterImplement||function(){};var G=J.generics;G=(G!==false);var H=J.legacy; +var E=J.initialize;var B=J.protect;var A=J.name;var C=E||H;C.constructor=Native;C.$family={name:"native"};if(H&&E){C.prototype=H.prototype;}C.prototype.constructor=C; +if(A){var D=A.toLowerCase();C.prototype.$family={name:D};Native.typize(C,D);}var I=function(M,K,N,L){if(!B||L||!M.prototype[K]){M.prototype[K]=N;}if(G){Native.genericize(M,K,B); +}F.call(M,K,N);return M;};C.implement=function(L,K,N){if(typeof L=="string"){return I(this,L,K,N);}for(var M in L){I(this,M,L[M],K);}return this;};C.alias=function(M,K,N){if(typeof M=="string"){M=this.prototype[M]; +if(M){I(this,K,M,N);}}else{for(var L in M){this.alias(L,M[L],K);}}return this;};return C;};Native.implement=function(D,C){for(var B=0,A=D.length;B-1:this.indexOf(A)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,"");},clean:function(){return this.replace(/\s+/g," ").trim(); +},camelCase:function(){return this.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(A){return("-"+A.charAt(0).toLowerCase()); +});},capitalize:function(){return this.replace(/\b[a-z]/g,function(A){return A.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1"); +},toInt:function(A){return parseInt(this,A||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(B){var A=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); +return(A)?A.slice(1).hexToRgb(B):null;},rgbToHex:function(B){var A=this.match(/\d{1,3}/g);return(A)?A.rgbToHex(B):null;},stripScripts:function(B){var A=""; +var C=this.replace(/]*>([\s\S]*?)<\/script>/gi,function(){A+=arguments[1]+"\n";return"";});if(B===true){$exec(A);}else{if($type(B)=="function"){B(A,C); +}}return C;},substitute:function(A,B){return this.replace(B||(/\\?\{([^}]+)\}/g),function(D,C){if(D.charAt(0)=="\\"){return D.slice(1);}return(A[C]!=undefined)?A[C]:""; +});}});Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(B){for(var A in this){if(this.hasOwnProperty(A)&&this[A]===B){return A;}}return null; +},hasValue:function(A){return(Hash.keyOf(this,A)!==null);},extend:function(A){Hash.each(A,function(C,B){Hash.set(this,B,C);},this);return this;},combine:function(A){Hash.each(A,function(C,B){Hash.include(this,B,C); +},this);return this;},erase:function(A){if(this.hasOwnProperty(A)){delete this[A];}return this;},get:function(A){return(this.hasOwnProperty(A))?this[A]:null; +},set:function(A,B){if(!this[A]||this.hasOwnProperty(A)){this[A]=B;}return this;},empty:function(){Hash.each(this,function(B,A){delete this[A];},this); +return this;},include:function(B,C){var A=this[B];if(A==undefined){this[B]=C;}return this;},map:function(B,C){var A=new Hash;Hash.each(this,function(E,D){A.set(D,B.call(C,E,D,this)); +},this);return A;},filter:function(B,C){var A=new Hash;Hash.each(this,function(E,D){if(B.call(C,E,D,this)){A.set(D,E);}},this);return A;},every:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&!B.call(C,this[A],A)){return false; +}}return true;},some:function(B,C){for(var A in this){if(this.hasOwnProperty(A)&&B.call(C,this[A],A)){return true;}}return false;},getKeys:function(){var A=[]; +Hash.each(this,function(C,B){A.push(B);});return A;},getValues:function(){var A=[];Hash.each(this,function(B){A.push(B);});return A;},toQueryString:function(A){var B=[]; +Hash.each(this,function(F,E){if(A){E=A+"["+E+"]";}var D;switch($type(F)){case"object":D=Hash.toQueryString(F,E);break;case"array":var C={};F.each(function(H,G){C[G]=H; +});D=Hash.toQueryString(C,E);break;default:D=E+"="+encodeURIComponent(F);}if(F!=undefined){B.push(D);}});return B.join("&");}});Hash.alias({keyOf:"indexOf",hasValue:"contains"}); +var Event=new Native({name:"Event",initialize:function(A,F){F=F||window;var K=F.document;A=A||F.event;if(A.$extended){return A;}this.$extended=true;var J=A.type; +var G=A.target||A.srcElement;while(G&&G.nodeType==3){G=G.parentNode;}if(J.test(/key/)){var B=A.which||A.keyCode;var M=Event.Keys.keyOf(B);if(J=="keydown"){var D=B-111; +if(D>0&&D<13){M="f"+D;}}M=M||String.fromCharCode(B).toLowerCase();}else{if(J.match(/(click|mouse|menu)/i)){K=(!K.compatMode||K.compatMode=="CSS1Compat")?K.html:K.body; +var I={x:A.pageX||A.clientX+K.scrollLeft,y:A.pageY||A.clientY+K.scrollTop};var C={x:(A.pageX)?A.pageX-F.pageXOffset:A.clientX,y:(A.pageY)?A.pageY-F.pageYOffset:A.clientY}; +if(J.match(/DOMMouseScroll|mousewheel/)){var H=(A.wheelDelta)?A.wheelDelta/120:-(A.detail||0)/3;}var E=(A.which==3)||(A.button==2);var L=null;if(J.match(/over|out/)){switch(J){case"mouseover":L=A.relatedTarget||A.fromElement; +break;case"mouseout":L=A.relatedTarget||A.toElement;}if(!(function(){while(L&&L.nodeType==3){L=L.parentNode;}return true;}).create({attempt:Browser.Engine.gecko})()){L=false; +}}}}return $extend(this,{event:A,type:J,page:I,client:C,rightClick:E,wheel:H,relatedTarget:L,target:G,code:B,key:M,shift:A.shiftKey,control:A.ctrlKey,alt:A.altKey,meta:A.metaKey}); +}});Event.Keys=new Hash({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Event.implement({stop:function(){return this.stopPropagation().preventDefault(); +},stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault(); +}else{this.event.returnValue=false;}return this;}});var Class=new Native({name:"Class",initialize:function(B){B=B||{};var A=function(E){for(var D in this){this[D]=$unlink(this[D]); +}for(var F in Class.Mutators){if(!this[F]){continue;}Class.Mutators[F](this,this[F]);delete this[F];}this.constructor=A;if(E===$empty){return this;}var C=(this.initialize)?this.initialize.apply(this,arguments):this; +if(this.options&&this.options.initialize){this.options.initialize.call(this);}return C;};$extend(A,this);A.constructor=Class;A.prototype=B;return A;}}); +Class.implement({implement:function(){Class.Mutators.Implements(this.prototype,Array.slice(arguments));return this;}});Class.Mutators={Implements:function(A,B){$splat(B).each(function(C){$extend(A,($type(C)=="class")?new C($empty):C); +});},Extends:function(self,klass){var instance=new klass($empty);delete instance.parent;delete instance.parentOf;for(var key in instance){var current=self[key],previous=instance[key]; +if(current==undefined){self[key]=previous;continue;}var ctype=$type(current),ptype=$type(previous);if(ctype!=ptype){continue;}switch(ctype){case"function":if(!arguments.callee.caller){self[key]=eval("("+String(current).replace(/\bthis\.parent\(\s*(\))?/g,function(full,close){return"arguments.callee._parent_.call(this"+(close||", "); +})+")");}self[key]._parent_=previous;break;case"object":self[key]=$merge(previous,current);}}self.parent=function(){return arguments.callee.caller._parent_.apply(this,arguments); +};self.parentOf=function(descendant){return descendant._parent_.apply(this,Array.slice(arguments,1));};}};var Chain=new Class({chain:function(){this.$chain=(this.$chain||[]).extend(arguments); +return this;},callChain:function(){return(this.$chain&&this.$chain.length)?this.$chain.shift().apply(this,arguments):false;},clearChain:function(){if(this.$chain){this.$chain.empty(); +}return this;}});var Events=new Class({addEvent:function(C,B,A){C=Events.removeOn(C);if(B!=$empty){this.$events=this.$events||{};this.$events[C]=this.$events[C]||[]; +this.$events[C].include(B);if(A){B.internal=true;}}return this;},addEvents:function(A){for(var B in A){this.addEvent(B,A[B]);}return this;},fireEvent:function(C,B,A){C=Events.removeOn(C); +if(!this.$events||!this.$events[C]){return this;}this.$events[C].each(function(D){D.create({bind:this,delay:A,"arguments":B})();},this);return this;},removeEvent:function(B,A){B=Events.removeOn(B); +if(!this.$events||!this.$events[B]){return this;}if(!A.internal){this.$events[B].erase(A);}return this;},removeEvents:function(C){for(var D in this.$events){if(C&&C!=D){continue; +}var B=this.$events[D];for(var A=B.length;A--;A){this.removeEvent(D,B[A]);}}return this;}});Events.removeOn=function(A){return A.replace(/^on([A-Z])/,function(B,C){return C.toLowerCase(); +});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent){return this;}for(var A in this.options){if($type(this.options[A])!="function"||!(/^on[A-Z]/).test(A)){continue; +}this.addEvent(A,this.options[A]);delete this.options[A];}return this;}});Document.implement({newElement:function(A,B){if(Browser.Engine.trident&&B){["name","type","checked"].each(function(C){if(!B[C]){return ; +}A+=" "+C+'="'+B[C]+'"';if(C!="checked"){delete B[C];}});A="<"+A+">";}return $.element(this.createElement(A)).set(B);},newTextNode:function(A){return this.createTextNode(A); +},getDocument:function(){return this;},getWindow:function(){return this.defaultView||this.parentWindow;},purge:function(){var C=this.getElementsByTagName("*"); +for(var B=0,A=C.length;B1);A.each(function(E){var F=this.getElementsByTagName(E.trim());(B)?C.extend(F):C=F;},this);return new Elements(C,{ddup:B,cash:!D}); +}});Element.Storage={get:function(A){return(this[A]||(this[A]={}));}};Element.Inserters=new Hash({before:function(B,A){if(A.parentNode){A.parentNode.insertBefore(B,A); +}},after:function(B,A){if(!A.parentNode){return ;}var C=A.nextSibling;(C)?A.parentNode.insertBefore(B,C):A.parentNode.appendChild(B);},bottom:function(B,A){A.appendChild(B); +},top:function(B,A){var C=A.firstChild;(C)?A.insertBefore(B,C):A.appendChild(B);}});Element.Inserters.inside=Element.Inserters.bottom;Element.Inserters.each(function(C,B){var A=B.capitalize(); +Element.implement("inject"+A,function(D){C(this,$(D,true));return this;});Element.implement("grab"+A,function(D){C($(D,true),this);return this;});});Element.implement({getDocument:function(){return this.ownerDocument; +},getWindow:function(){return this.ownerDocument.getWindow();},getElementById:function(D,C){var B=this.ownerDocument.getElementById(D);if(!B){return null; +}for(var A=B.parentNode;A!=this;A=A.parentNode){if(!A){return null;}}return $.element(B,C);},set:function(D,B){switch($type(D)){case"object":for(var C in D){this.set(C,D[C]); +}break;case"string":var A=Element.Properties.get(D);(A&&A.set)?A.set.apply(this,Array.slice(arguments,1)):this.setProperty(D,B);}return this;},get:function(B){var A=Element.Properties.get(B); +return(A&&A.get)?A.get.apply(this,Array.slice(arguments,1)):this.getProperty(B);},erase:function(B){var A=Element.Properties.get(B);(A&&A.erase)?A.erase.apply(this,Array.slice(arguments,1)):this.removeProperty(B); +return this;},match:function(A){return(!A||Element.get(this,"tag")==A);},inject:function(B,A){Element.Inserters.get(A||"bottom")(this,$(B,true));return this; +},wraps:function(B,A){B=$(B,true);return this.replaces(B).grab(B,A);},grab:function(B,A){Element.Inserters.get(A||"bottom")($(B,true),this);return this; +},appendText:function(B,A){return this.grab(this.getDocument().newTextNode(B),A);},adopt:function(){Array.flatten(arguments).each(function(A){A=$(A,true); +if(A){this.appendChild(A);}},this);return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this;},clone:function(D,C){switch($type(this)){case"element":var H={}; +for(var G=0,E=this.attributes.length;G1),cash:!G});}});Element.implement({match:function(B){if(!B){return true; +}var D=Selectors.Utils.parseTagAndID(B);var A=D[0],E=D[1];if(!Selectors.Filters.byID(this,E)||!Selectors.Filters.byTag(this,A)){return false;}var C=Selectors.Utils.parseSelector(B); +return(C)?Selectors.Utils.filter(this,C,{}):true;}});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)["']?(.*?)["']?)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)}; +Selectors.Utils={chk:function(B,C){if(!C){return true;}var A=$uid(B);if(!C[A]){return C[A]=true;}return false;},parseNthArgument:function(F){if(Selectors.Cache.nth[F]){return Selectors.Cache.nth[F]; +}var C=F.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!C){return false;}var E=parseInt(C[1]);var B=(E||E===0)?E:1;var D=C[2]||false;var A=parseInt(C[3])||0; +if(B!=0){A--;while(A<1){A+=B;}while(A>=B){A-=B;}}else{B=A;D="index";}switch(D){case"n":C={a:B,b:A,special:"n"};break;case"odd":C={a:2,b:0,special:"n"}; +break;case"even":C={a:2,b:1,special:"n"};break;case"first":C={a:0,special:"index"};break;case"last":C={special:"last-child"};break;case"only":C={special:"only-child"}; +break;default:C={a:(B-1),special:"index"};}return Selectors.Cache.nth[F]=C;},parseSelector:function(E){if(Selectors.Cache.parsed[E]){return Selectors.Cache.parsed[E]; +}var D,H={classes:[],pseudos:[],attributes:[]};while((D=Selectors.RegExps.combined.exec(E))){var I=D[1],G=D[2],F=D[3],B=D[4],C=D[5],J=D[6];if(I){H.classes.push(I); +}else{if(C){var A=Selectors.Pseudo.get(C);if(A){H.pseudos.push({parser:A,argument:J});}else{H.attributes.push({name:C,operator:"=",value:J});}}else{if(G){H.attributes.push({name:G,operator:F,value:B}); +}}}}if(!H.classes.length){delete H.classes;}if(!H.attributes.length){delete H.attributes;}if(!H.pseudos.length){delete H.pseudos;}if(!H.classes&&!H.attributes&&!H.pseudos){H=null; +}return Selectors.Cache.parsed[E]=H;},parseTagAndID:function(B){var A=B.match(Selectors.RegExps.tag);var C=B.match(Selectors.RegExps.id);return[(A)?A[1]:"*",(C)?C[1]:false]; +},filter:function(F,C,E){var D;if(C.classes){for(D=C.classes.length;D--;D){var G=C.classes[D];if(!Selectors.Filters.byClass(F,G)){return false;}}}if(C.attributes){for(D=C.attributes.length; +D--;D){var B=C.attributes[D];if(!Selectors.Filters.byAttribute(F,B.name,B.operator,B.value)){return false;}}}if(C.pseudos){for(D=C.pseudos.length;D--;D){var A=C.pseudos[D]; +if(!Selectors.Filters.byPseudo(F,A.parser,A.argument,E)){return false;}}}return true;},getByTagAndID:function(B,A,D){if(D){var C=(B.getElementById)?B.getElementById(D,true):Element.getElementById(B,D,true); +return(C&&Selectors.Filters.byTag(C,A))?[C]:[];}else{return B.getElementsByTagName(A);}},search:function(J,I,O){var B=[];var C=I.trim().replace(Selectors.RegExps.splitter,function(Z,Y,X){B.push(Y); +return":)"+X;}).split(":)");var K,F,E,V;for(var U=0,Q=C.length;U":function(H,G,I,A,F){var C=Selectors.Utils.getByTagAndID(G,I,A);for(var E=0,D=C.length;EA){return false; +}}return(C==A);},even:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n+1",A);},odd:function(B,A){return Selectors.Pseudo["nth-child"].call(this,"2n",A); +}});Element.Events.domready={onAdd:function(A){if(Browser.loaded){A.call(this);}}};(function(){var B=function(){if(Browser.loaded){return ;}Browser.loaded=true; +window.fireEvent("domready");document.fireEvent("domready");};switch(Browser.Engine.name){case"webkit":(function(){(["loaded","complete"].contains(document.readyState))?B():arguments.callee.delay(50); +})();break;case"trident":var A=document.createElement("div");(function(){($try(function(){A.doScroll("left");return $(A).inject(document.body).set("html","temp").dispose(); +}))?B():arguments.callee.delay(50);})();break;default:window.addEvent("load",B);document.addEvent("DOMContentLoaded",B);}})();var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(B,A){this.key=B; +this.setOptions(A);},write:function(B){B=encodeURIComponent(B);if(this.options.domain){B+="; domain="+this.options.domain;}if(this.options.path){B+="; path="+this.options.path; +}if(this.options.duration){var A=new Date();A.setTime(A.getTime()+this.options.duration*24*60*60*1000);B+="; expires="+A.toGMTString();}if(this.options.secure){B+="; secure"; +}this.options.document.cookie=this.key+"="+B;return this;},read:function(){var A=this.options.document.cookie.match("(?:^|;)\\s*"+this.key.escapeRegExp()+"=([^;]*)"); +return(A)?decodeURIComponent(A[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write("");return this;}});Cookie.write=function(B,C,A){return new Cookie(B,A).write(C); +};Cookie.read=function(A){return new Cookie(A).read();};Cookie.dispose=function(B,A){return new Cookie(B,A).dispose();};var Request=new Class({Implements:[Chain,Events,Options],options:{url:"",data:"",headers:{"X-Requested-With":"XMLHttpRequest",Accept:"text/javascript, text/html, application/xml, text/xml, */*"},async:true,format:false,method:"post",link:"ignore",isSuccess:null,emulation:true,urlEncoded:true,encoding:"utf-8",evalScripts:false,evalResponse:false},initialize:function(A){this.xhr=new Browser.Request(); +this.setOptions(A);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running){return ; +}this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML}; +this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}this.xhr.onreadystatechange=$empty;},isSuccess:function(){return((this.status>=200)&&(this.status<300)); +},processScripts:function(A){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){return $exec(A);}return A.stripScripts(this.options.evalScripts); +},success:function(B,A){this.onSuccess(this.processScripts(B),A);},onSuccess:function(){this.fireEvent("complete",arguments).fireEvent("success",arguments).callChain(); +},failure:function(){this.onFailure();},onFailure:function(){this.fireEvent("complete").fireEvent("failure",this.xhr);},setHeader:function(A,B){this.headers.set(A,B); +return this;},getHeader:function(A){return $try(function(){return this.xhr.getResponseHeader(A);}.bind(this));},check:function(A){if(!this.running){return true; +}switch(this.options.link){case"cancel":this.cancel();return true;case"chain":this.chain(A.bind(this,Array.slice(arguments,1)));return false;}return false; +},send:function(I){if(!this.check(arguments.callee,I)){return this;}this.running=true;var G=$type(I);if(G=="string"||G=="element"){I={data:I};}var D=this.options; +I=$extend({data:D.data,url:D.url,method:D.method},I);var E=I.data,B=I.url,A=I.method;switch($type(E)){case"element":E=$(E).toQueryString();break;case"object":case"hash":E=Hash.toQueryString(E); +}if(this.options.format){var H="format="+this.options.format;E=(E)?H+"&"+E:H;}if(this.options.emulation&&["put","delete"].contains(A)){var F="_method="+A; +E=(E)?F+"&"+E:F;A="post";}if(this.options.urlEncoded&&A=="post"){var C=(this.options.encoding)?"; charset="+this.options.encoding:"";this.headers.set("Content-type","application/x-www-form-urlencoded"+C); +}if(E&&A=="get"){B=B+(B.contains("?")?"&":"?")+E;E=null;}this.xhr.open(A.toUpperCase(),B,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this); +this.headers.each(function(K,J){if(!$try(function(){this.xhr.setRequestHeader(J,K);return true;}.bind(this))){this.fireEvent("exception",[J,K]);}},this); +this.fireEvent("request");this.xhr.send(E);if(!this.options.async){this.onStateChange();}return this;},cancel:function(){if(!this.running){return this; +}this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;this.xhr=new Browser.Request();this.fireEvent("cancel");return this;}});(function(){var A={}; +["get","post","put","delete","GET","POST","PUT","DELETE"].each(function(B){A[B]=function(){var C=Array.link(arguments,{url:String.type,data:$defined}); +return this.send($extend(C,{method:B.toLowerCase()}));};});Request.implement(A);})();Element.Properties.send={set:function(A){var B=this.retrieve("send"); +if(B){B.cancel();}return this.eliminate("send").store("send:options",$extend({data:this,link:"cancel",method:this.get("method")||"post",url:this.get("action")},A)); +},get:function(A){if(A||!this.retrieve("send")){if(A||!this.retrieve("send:options")){this.set("send",A);}this.store("send",new Request(this.retrieve("send:options"))); }return this.retrieve("send");}};Element.implement({send:function(A){var B=this.get("send");B.send({data:this,url:A||B.options.url});return this;}}); \ No newline at end of file diff --git a/htdocs/sqlbuddy/js/movement.js b/htdocs/sqlbuddy/js/movement.js index af2ea1959..3724a91ec 100755 --- a/htdocs/sqlbuddy/js/movement.js +++ b/htdocs/sqlbuddy/js/movement.js @@ -1,206 +1,206 @@ -var mouseX = -1; -var mouseY = -1; -var lastWidth = -1; -var lastHeight = -1; -var lastLeft = -1; -var lastTop = -1; -var activeContent; -var compX = 0; -var compY = 0; -var activeColumnId = -1; -var activeColumn; -var styleNodeKeys = []; -var styleNodes = []; - -function startResize(e) { - var event = new Event(e); - - activeWindow = event.target; - while (activeWindow != null && activeWindow.className.indexOf("fulltextwin") == -1) { - activeWindow = activeWindow.parentNode; - } - - activeContent = $E(".fulltextcontent", activeWindow); - - lastWidth = parseInt(activeWindow.offsetWidth); - lastHeight = parseInt(activeContent.offsetHeight); - mouseX = event.page.x; - mouseY = event.page.y; - - activeContent.style.height = lastHeight + "px"; - activeContent.style.maxHeight = ''; - - window.addEvent("mousemove", doResize); - window.addEvent("mouseup", endResize); - - return false; -} - -function doResize(e) { - if (activeWindow) { - var event = new Event(e); - - var diffX = event.page.x - mouseX; - var diffY = event.page.y - mouseY; - - if (compX > 0 && compX > diffX) { - compX -= diffX; - diffX = 0; - } else if (compX > 0) { - diffX -= compX; - compX = 0; - } - - if (compY > 0 && compY > diffY) { - compY -= diffY; - diffY = 0; - } else if (compY > 0) { - diffY -= compY; - compY = 0; - } - - lastWidth = lastWidth + diffX; - lastHeight = lastHeight + diffY; - - if (lastWidth < 175) { - compX += 175 - lastWidth; - lastWidth = 175; - } - - if (lastHeight < 100) { - compY += 100 - lastHeight; - lastHeight = 100; - } - - mouseX = event.page.x; - mouseY = event.page.y; - - activeWindow.style.width = lastWidth + "px"; - activeContent.style.height = lastHeight + "px"; - } -} - -function endResize() { - activeWindow = null; - activeContent = null; - compX = 0; - compY = 0; - window.removeEvent("mousemove", doResize); - window.removeEvent("mouseup", endResize); -} - -function startDrag(e) { - var event = new Event(e); - - activeWindow = event.target; - while (activeWindow != null && activeWindow.className.indexOf("fulltextwin") == -1) { - activeWindow = activeWindow.parentNode; - } - - lastLeft = activeWindow.style.left; - lastLeft = parseInt(lastLeft.substring(0, lastLeft.length - 2)); - lastTop = activeWindow.style.top; - lastTop = parseInt(lastTop.substring(0, lastTop.length - 2)); - mouseX = event.page.x; - mouseY = event.page.y; - - window.addEvent("mousemove", doDrag); - window.addEvent("mouseup", endDrag); - - return false; -} - -function doDrag(e) { - if (activeWindow) { - var event = new Event(e); - - var diffX = event.page.x - mouseX; - var diffY = event.page.y - mouseY; - - lastLeft = lastLeft + diffX; - lastTop = lastTop + diffY; - mouseX = event.page.x; - mouseY = event.page.y; - - activeWindow.style.left = lastLeft + "px"; - activeWindow.style.top = lastTop + "px"; - } -} - -function endDrag() { - activeWindow = null; - window.removeEvent("mousemove", doDrag); - window.removeEvent("mouseup", endDrag); -} - -function startColumnResize(e) { - var event = new Event(e); - - activeColumn = $(event.target.offsetParent.previousSibling.firstChild); - - activeColumnId = parseInt(activeColumn.getProperty("column")); - - lastWidth = parseInt(activeColumn.clientWidth) - 11; // -11 to account for padding - mouseX = event.page.x; - - document.body.style.cursor = "ew-resize"; - - window.addEvent("mousemove", columnResize); - window.addEvent("mouseup", endColumnResize); - - return false; -} - -function columnResize(e) { - if (activeColumn) { - var event = new Event(e); - - var diff = (event.page.x - mouseX); - - lastWidth = (lastWidth + diff); - mouseX = event.page.x; - - var removeLater = -1; - var keyName = 'pane' + sb.topTab + '_' + activeColumnId; - - for (var i=0; i= 0) { - styleNodes.splice(removeLater, 1); - styleNodeKeys.splice(removeLater, 1); - } - - var newNode = new Element("style"); - newNode.setAttribute("type", "text/css"); - - newNode.appendText("#pane" + sb.topTab + " .column" + activeColumnId + " { width: " + lastWidth + "px !important }"); - document.getElementsByTagName("head")[0].appendChild(newNode); - - styleNodes.push(newNode); - styleNodeKeys.push(keyName); - } -} - -function endColumnResize() { - document.body.style.cursor = ""; - activeColumn = null; - window.removeEvent("mousemove", columnResize); - window.removeEvent("mouseup", endColumnResize); -} - -function clearColumnSizes() { - if (styleNodes.length > 0) { - for (var i=0; i 0 && compX > diffX) { + compX -= diffX; + diffX = 0; + } else if (compX > 0) { + diffX -= compX; + compX = 0; + } + + if (compY > 0 && compY > diffY) { + compY -= diffY; + diffY = 0; + } else if (compY > 0) { + diffY -= compY; + compY = 0; + } + + lastWidth = lastWidth + diffX; + lastHeight = lastHeight + diffY; + + if (lastWidth < 175) { + compX += 175 - lastWidth; + lastWidth = 175; + } + + if (lastHeight < 100) { + compY += 100 - lastHeight; + lastHeight = 100; + } + + mouseX = event.page.x; + mouseY = event.page.y; + + activeWindow.style.width = lastWidth + "px"; + activeContent.style.height = lastHeight + "px"; + } +} + +function endResize() { + activeWindow = null; + activeContent = null; + compX = 0; + compY = 0; + window.removeEvent("mousemove", doResize); + window.removeEvent("mouseup", endResize); +} + +function startDrag(e) { + var event = new Event(e); + + activeWindow = event.target; + while (activeWindow != null && activeWindow.className.indexOf("fulltextwin") == -1) { + activeWindow = activeWindow.parentNode; + } + + lastLeft = activeWindow.style.left; + lastLeft = parseInt(lastLeft.substring(0, lastLeft.length - 2)); + lastTop = activeWindow.style.top; + lastTop = parseInt(lastTop.substring(0, lastTop.length - 2)); + mouseX = event.page.x; + mouseY = event.page.y; + + window.addEvent("mousemove", doDrag); + window.addEvent("mouseup", endDrag); + + return false; +} + +function doDrag(e) { + if (activeWindow) { + var event = new Event(e); + + var diffX = event.page.x - mouseX; + var diffY = event.page.y - mouseY; + + lastLeft = lastLeft + diffX; + lastTop = lastTop + diffY; + mouseX = event.page.x; + mouseY = event.page.y; + + activeWindow.style.left = lastLeft + "px"; + activeWindow.style.top = lastTop + "px"; + } +} + +function endDrag() { + activeWindow = null; + window.removeEvent("mousemove", doDrag); + window.removeEvent("mouseup", endDrag); +} + +function startColumnResize(e) { + var event = new Event(e); + + activeColumn = $(event.target.offsetParent.previousSibling.firstChild); + + activeColumnId = parseInt(activeColumn.getProperty("column")); + + lastWidth = parseInt(activeColumn.clientWidth) - 11; // -11 to account for padding + mouseX = event.page.x; + + document.body.style.cursor = "ew-resize"; + + window.addEvent("mousemove", columnResize); + window.addEvent("mouseup", endColumnResize); + + return false; +} + +function columnResize(e) { + if (activeColumn) { + var event = new Event(e); + + var diff = (event.page.x - mouseX); + + lastWidth = (lastWidth + diff); + mouseX = event.page.x; + + var removeLater = -1; + var keyName = 'pane' + sb.topTab + '_' + activeColumnId; + + for (var i=0; i= 0) { + styleNodes.splice(removeLater, 1); + styleNodeKeys.splice(removeLater, 1); + } + + var newNode = new Element("style"); + newNode.setAttribute("type", "text/css"); + + newNode.appendText("#pane" + sb.topTab + " .column" + activeColumnId + " { width: " + lastWidth + "px !important }"); + document.getElementsByTagName("head")[0].appendChild(newNode); + + styleNodes.push(newNode); + styleNodeKeys.push(keyName); + } +} + +function endColumnResize() { + document.body.style.cursor = ""; + activeColumn = null; + window.removeEvent("mousemove", columnResize); + window.removeEvent("mouseup", endColumnResize); +} + +function clearColumnSizes() { + if (styleNodes.length > 0) { + for (var i=0; i - -*/ - -include "functions.php"; - -$adapter = (isset($sbconfig['DefaultAdapter'])) ? $sbconfig['DefaultAdapter'] : "mysql"; -$host = (isset($sbconfig['DefaultHost'])) ? $sbconfig['DefaultHost'] : "localhost"; -$user = (isset($sbconfig['DefaultUser'])) ? $sbconfig['DefaultUser'] : "root"; -$pass = (isset($sbconfig['DefaultPass'])) ? $sbconfig['DefaultPass'] : ""; - -// SQLite only -$database = (isset($sbconfig['DefaultDatabase'])) ? $sbconfig['DefaultDatabase'] : ""; - -if ($_POST) { - if (isset($_POST['ADAPTER'])) - $adapter = $_POST['ADAPTER']; - - if (isset($_POST['HOST'])) - $host = $_POST['HOST']; - - if (isset($_POST['USER'])) - $user = $_POST['USER']; - - if (isset($_POST['PASS'])) - $pass = $_POST['PASS']; - - if (isset($_POST['DATABASE'])) - $database = $_POST['DATABASE']; -} - -if (!in_array($adapter, $adapterList)) { - $adapter = "mysql"; -} - -if (($adapter != "sqlite" && $host && $user && ($pass || $_POST)) || ($adapter == "sqlite" && $database)) { - - if ($adapter == "sqlite") { - $connString = "sqlite:database=$database"; - $connCheck = new SQL($connString); - $user = ""; - $pass = ""; - } else { - $connString = "$adapter:host=$host"; - $connCheck = new SQL($connString, $user, $pass); - } - - if ($connCheck->isConnected()) { - $_SESSION['SB_LOGIN'] = true; - $_SESSION['SB_LOGIN_STRING'] = $connString; - $_SESSION['SB_LOGIN_USER'] = $user; - $_SESSION['SB_LOGIN_PASS'] = $pass; - - $path = $_SERVER["SCRIPT_NAME"]; - $pathSplit = explode("/", $path); - - $redirect = ""; - - for ($i=0; $i - - - - SQL Buddy - - " /> - " /> - " media="print" /> - " /> - - - - - - -
      -
      -
      -
      - - - - - - - - -

      - - - - - - '; - } - if (isset($_GET['timeout'])) { - echo ''; - } - - if (sizeof($adapterList) > 1) { - - ?> - - - - - -

      ' . $error . '
      ' . __("Your session has timed out. Please login again.") . '
      - -
      - > - - - - - - - - - - - - - - > - - - - - - - - - - -
      " />
      - -
      -
      -
      -
      - - + + +*/ + +include "functions.php"; + +$adapter = (isset($sbconfig['DefaultAdapter'])) ? $sbconfig['DefaultAdapter'] : "mysql"; +$host = (isset($sbconfig['DefaultHost'])) ? $sbconfig['DefaultHost'] : "localhost"; +$user = (isset($sbconfig['DefaultUser'])) ? $sbconfig['DefaultUser'] : "root"; +$pass = (isset($sbconfig['DefaultPass'])) ? $sbconfig['DefaultPass'] : ""; + +// SQLite only +$database = (isset($sbconfig['DefaultDatabase'])) ? $sbconfig['DefaultDatabase'] : ""; + +if ($_POST) { + if (isset($_POST['ADAPTER'])) + $adapter = $_POST['ADAPTER']; + + if (isset($_POST['HOST'])) + $host = $_POST['HOST']; + + if (isset($_POST['USER'])) + $user = $_POST['USER']; + + if (isset($_POST['PASS'])) + $pass = $_POST['PASS']; + + if (isset($_POST['DATABASE'])) + $database = $_POST['DATABASE']; +} + +if (!in_array($adapter, $adapterList)) { + $adapter = "mysql"; +} + +if (($adapter != "sqlite" && $host && $user && ($pass || $_POST)) || ($adapter == "sqlite" && $database)) { + + if ($adapter == "sqlite") { + $connString = "sqlite:database=$database"; + $connCheck = new SQL($connString); + $user = ""; + $pass = ""; + } else { + $connString = "$adapter:host=$host"; + $connCheck = new SQL($connString, $user, $pass); + } + + if ($connCheck->isConnected()) { + $_SESSION['SB_LOGIN'] = true; + $_SESSION['SB_LOGIN_STRING'] = $connString; + $_SESSION['SB_LOGIN_USER'] = $user; + $_SESSION['SB_LOGIN_PASS'] = $pass; + + $path = $_SERVER["SCRIPT_NAME"]; + $pathSplit = explode("/", $path); + + $redirect = ""; + + for ($i=0; $i + + + + SQL Buddy + + " /> + " /> + " media="print" /> + " /> + + + + + + +
      +
      +
      +
      + + + + + + + + +

      + + + + + + '; + } + if (isset($_GET['timeout'])) { + echo ''; + } + + if (sizeof($adapterList) > 1) { + + ?> + + + + + +

      ' . $error . '
      ' . __("Your session has timed out. Please login again.") . '
      + +
      + > + + + + + + + + + + + + + + > + + + + + + + + + + +
      " />
      + +
      +
      +
      +
      + + \ No newline at end of file diff --git a/htdocs/sqlbuddy/logout.php b/htdocs/sqlbuddy/logout.php index 813835423..14daaef39 100755 --- a/htdocs/sqlbuddy/logout.php +++ b/htdocs/sqlbuddy/logout.php @@ -1,41 +1,41 @@ - - -*/ - -if (!session_id()) - session_start(); - -if (isset($_SESSION['SB_LOGIN'])) { - $_SESSION['SB_LOGIN'] = null; - unset($GLOBALS['_SESSION']['SB_LOGIN']); -} - -if (isset($_SESSION['SB_LOGIN_STRING'])) { - $_SESSION['SB_LOGIN_STRING'] = null; - unset($GLOBALS['_SESSION']['SB_LOGIN_STRING']); -} - -if (isset($_SESSION['SB_LOGIN_USER'])) { - $_SESSION['SB_LOGIN_USER'] = null; - unset($GLOBALS['_SESSION']['SB_LOGIN_USER']); -} - -if (isset($_SESSION['SB_LOGIN_PASS'])) { - $_SESSION['SB_LOGIN_PASS'] = null; - unset($GLOBALS['_SESSION']['SB_LOGIN_PASS']); -} - -header("Location: login.php"); - + + +*/ + +if (!session_id()) + session_start(); + +if (isset($_SESSION['SB_LOGIN'])) { + $_SESSION['SB_LOGIN'] = null; + unset($GLOBALS['_SESSION']['SB_LOGIN']); +} + +if (isset($_SESSION['SB_LOGIN_STRING'])) { + $_SESSION['SB_LOGIN_STRING'] = null; + unset($GLOBALS['_SESSION']['SB_LOGIN_STRING']); +} + +if (isset($_SESSION['SB_LOGIN_USER'])) { + $_SESSION['SB_LOGIN_USER'] = null; + unset($GLOBALS['_SESSION']['SB_LOGIN_USER']); +} + +if (isset($_SESSION['SB_LOGIN_PASS'])) { + $_SESSION['SB_LOGIN_PASS'] = null; + unset($GLOBALS['_SESSION']['SB_LOGIN_PASS']); +} + +header("Location: login.php"); + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/query.php b/htdocs/sqlbuddy/query.php index 81e58e7f6..1141b81d1 100755 --- a/htdocs/sqlbuddy/query.php +++ b/htdocs/sqlbuddy/query.php @@ -1,78 +1,78 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($_POST['query'])) - $query = $_POST['query']; - -echo '
      '; - -if (isset($db)) { - echo '' . sprintf(__("Run a query on the %s database"), $db) . '.'; -} - -if (isset($query)) { - $displayQuery = $query; -} else if (isset($db) && isset($table) && $conn->getAdapter() == "mysql") { - $displayQuery = "SELECT * FROM `$table` LIMIT 100"; -} else if (isset($db) && isset($table) && $conn->getAdapter() == "sqlite") { - $displayQuery = "SELECT * FROM '$table' LIMIT 100"; -} - -?> - -
      - - - - - -
      - - - " /> -
      -
      - -
      - -'; - - require "includes/browse.php"; - - echo ''; -} - -?> - \ No newline at end of file diff --git a/htdocs/sqlbuddy/serve.php b/htdocs/sqlbuddy/serve.php index fcec1b681..685c9b821 100755 --- a/htdocs/sqlbuddy/serve.php +++ b/htdocs/sqlbuddy/serve.php @@ -1,116 +1,116 @@ - - -*/ - -include "config.php"; - -function compressCSS($input) { - // remove comments - $input = preg_replace("/\/\*.*\*\//Us", "", $input); - - // remove unnecessary characters - $input = str_replace(":0px", ":0", $input); - $input = str_replace(":0em", ":0", $input); - $input = str_replace(" 0px", " 0", $input); - $input = str_replace(" 0em", " 0", $input); - $input = str_replace(";}", "}", $input); - - // remove spaces, etc - $input = preg_replace('/\s\s+/', ' ', $input); - $input = str_replace(" {", "{", $input); - $input = str_replace("{ ", "{", $input); - $input = str_replace("\n{", "{", $input); - $input = str_replace("{\n", "{", $input); - $input = str_replace(" }", "}", $input); - $input = str_replace("} ", "}", $input); - $input = str_replace(": ", ":", $input); - $input = str_replace(" :", ":", $input); - $input = str_replace(";\n", ";", $input); - $input = str_replace(" ;", ";", $input); - $input = str_replace("; ", ";", $input); - $input = str_replace(", ", ",", $input); - - return trim($input); -} - -function compressJS($input) { - - // remove comments - $input = preg_replace("/\/\/.*\n/Us", "", $input); - $input = preg_replace("/\/\*.*\*\//Us", "", $input); - - // remove spaces, etc - $input = preg_replace("/\t/", "", $input); - $input = preg_replace("/\n\n+/m", "\n", $input); - $input = str_replace(";\n", ";", $input); - $input = str_replace(" = ", "=", $input); - $input = str_replace(" == ", "==", $input); - $input = str_replace(" || ", "||", $input); - $input = str_replace(" && ", "&&", $input); - $input = str_replace(")\n{", "){", $input); - $input = str_replace("if (", "if(", $input); - - return trim($input); -} - -if (isset($_GET['file'])) { - - $filename = $_GET['file']; - - if (!(strpos($filename, "css/") === 0 || strpos($filename, "themes/") === 0 || strpos($filename, "js/") === 0)) - exit; - - if (strpos($filename, "..") !== false) - exit; - - if (file_exists($filename)) { - if (extension_loaded('zlib') && ((isset($sbconfig['EnableGzip']) && $sbconfig['EnableGzip'] == true) || !isset($sbconfig['EnableGzip']))) { - ob_start("ob_gzhandler"); - } else { - ob_start(); - } - - $last_modified_time = filemtime($filename); - $etag = md5_file($filename); - - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $last_modified_time) . " GMT"); - header("Expires: " . gmdate("D, d M Y H:i:s", time()+24*60*60*60) . " GMT"); - header("Etag: $etag"); - - if ((array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER) && @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time) || (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag)) { - header("HTTP/1.1 304 Not Modified"); - exit; - } - - $contents = file_get_contents($filename); - - if (substr($filename, -4) == ".css") { - header("Content-Type: text/css; charset=utf-8"); - $contents = compressCSS($contents); - } else if (substr($filename, -3) == ".js" && strpos($filename, "mootools") === false) { - header("Content-Type: application/x-javascript; charset=utf-8"); - $contents = compressJS($contents); - } else if (substr($filename, -3) == ".js") { - header("Content-Type: application/x-javascript; charset=utf-8"); - } - - echo $contents; - - ob_end_flush(); - } else { - echo "File doesn't exist!"; - } -} - + + +*/ + +include "config.php"; + +function compressCSS($input) { + // remove comments + $input = preg_replace("/\/\*.*\*\//Us", "", $input); + + // remove unnecessary characters + $input = str_replace(":0px", ":0", $input); + $input = str_replace(":0em", ":0", $input); + $input = str_replace(" 0px", " 0", $input); + $input = str_replace(" 0em", " 0", $input); + $input = str_replace(";}", "}", $input); + + // remove spaces, etc + $input = preg_replace('/\s\s+/', ' ', $input); + $input = str_replace(" {", "{", $input); + $input = str_replace("{ ", "{", $input); + $input = str_replace("\n{", "{", $input); + $input = str_replace("{\n", "{", $input); + $input = str_replace(" }", "}", $input); + $input = str_replace("} ", "}", $input); + $input = str_replace(": ", ":", $input); + $input = str_replace(" :", ":", $input); + $input = str_replace(";\n", ";", $input); + $input = str_replace(" ;", ";", $input); + $input = str_replace("; ", ";", $input); + $input = str_replace(", ", ",", $input); + + return trim($input); +} + +function compressJS($input) { + + // remove comments + $input = preg_replace("/\/\/.*\n/Us", "", $input); + $input = preg_replace("/\/\*.*\*\//Us", "", $input); + + // remove spaces, etc + $input = preg_replace("/\t/", "", $input); + $input = preg_replace("/\n\n+/m", "\n", $input); + $input = str_replace(";\n", ";", $input); + $input = str_replace(" = ", "=", $input); + $input = str_replace(" == ", "==", $input); + $input = str_replace(" || ", "||", $input); + $input = str_replace(" && ", "&&", $input); + $input = str_replace(")\n{", "){", $input); + $input = str_replace("if (", "if(", $input); + + return trim($input); +} + +if (isset($_GET['file'])) { + + $filename = $_GET['file']; + + if (!(strpos($filename, "css/") === 0 || strpos($filename, "themes/") === 0 || strpos($filename, "js/") === 0)) + exit; + + if (strpos($filename, "..") !== false) + exit; + + if (file_exists($filename)) { + if (extension_loaded('zlib') && ((isset($sbconfig['EnableGzip']) && $sbconfig['EnableGzip'] == true) || !isset($sbconfig['EnableGzip']))) { + ob_start("ob_gzhandler"); + } else { + ob_start(); + } + + $last_modified_time = filemtime($filename); + $etag = md5_file($filename); + + header("Last-Modified: " . gmdate("D, d M Y H:i:s", $last_modified_time) . " GMT"); + header("Expires: " . gmdate("D, d M Y H:i:s", time()+24*60*60*60) . " GMT"); + header("Etag: $etag"); + + if ((array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER) && @strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time) || (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag)) { + header("HTTP/1.1 304 Not Modified"); + exit; + } + + $contents = file_get_contents($filename); + + if (substr($filename, -4) == ".css") { + header("Content-Type: text/css; charset=utf-8"); + $contents = compressCSS($contents); + } else if (substr($filename, -3) == ".js" && strpos($filename, "mootools") === false) { + header("Content-Type: application/x-javascript; charset=utf-8"); + $contents = compressJS($contents); + } else if (substr($filename, -3) == ".js") { + header("Content-Type: application/x-javascript; charset=utf-8"); + } + + echo $contents; + + ob_end_flush(); + } else { + echo "File doesn't exist!"; + } +} + ?> \ No newline at end of file diff --git a/htdocs/sqlbuddy/structure.php b/htdocs/sqlbuddy/structure.php index 858559f5e..969f047cf 100755 --- a/htdocs/sqlbuddy/structure.php +++ b/htdocs/sqlbuddy/structure.php @@ -1,775 +1,775 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -requireDatabaseAndTableBeDefined(); - -if (isset($db)) - $conn->selectDB($db); - -if (isset($_POST)) { - - // process form - add index - if (isset($_POST['INDEXTYPE'])) - $indexType = $_POST['INDEXTYPE']; - - if (isset($_POST['INDEXCOLUMNLIST'])) - $indexColumnList = $_POST['INDEXCOLUMNLIST']; - - if (isset($indexType) && isset($indexColumnList) && $indexType && $indexColumnList) { - $indexColumnList = implode("`, `", $indexColumnList); - - $indexQuery = "ALTER TABLE `$table` ADD "; - - if ($indexType == "INDEX") - $indexQuery .= "INDEX"; - else if ($indexType == "UNIQUE") - $indexQuery .= "UNIQUE"; - - $indexQuery .= " (`" . $indexColumnList . "`)"; - - $conn->query($indexQuery) or ($dbError = $conn->error()); - } - - ?> - - - - query($query) or ($dbError = $conn->error()); - } -} - -if (isset($dbError)) { - echo '
      ' . __("Error performing operation") . '

      ' . $dbError . '

      '; -} - -$structureSql = $conn->describeTable($table); - -if ($conn->getAdapter() == "mysql" && $conn->isResultSet($structureSql)) { - -?> - - - - - - -
      - - - - - -
      - - ' . __("Columns") . '    '; - - echo __("Select") . ':  ' . __("All") . '  ' . __("None") . ''; - echo '     ' . __("With selected") . ':  ' . __("Edit") . '  ' . __("Delete") . ''; - - ?> - -
      - - '; - - echo '
       
      '; - - echo '
      '; - echo '
      '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      ' . __("Name") . '
      ' . __("Type") . '
      ' . __("Default") . '
      '; - echo '
      '; - echo '
      '; - - echo '
      '; - - $m = 0; - - while ($structureRow = $conn->fetchAssoc($structureSql)) { - echo '
      '; - } - - echo '
      '; - - $structureSql = $conn->describeTable($table); - - echo '
      '; - - $m = 0; - - while ($structureRow = $conn->fetchAssoc($structureSql)) { - - echo '
      '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      ' . $structureRow['Field'] . '
      ' . $structureRow['Type'] . '
      ' . $structureRow['Default'] . '
      '; - echo '
      '; - - $fieldList[] = $structureRow['Field']; - - $m++; - } - - echo '
      '; - echo ''; - - ?> - -
      -

      - -
      - - - - - - - - - - - - - - - - - - - - - "; - echo __("Charset") . ":"; - echo ""; - echo ""; - } else { - echo ""; - echo ""; - } - - ?> - - - - - - - - - -
      - : - - - - : - - -
      - : - - - - : - - -
      - : - - - "; - echo ""; - echo "
      - : - - - - - -
      - :   - - " /> -
      -
      -
      - -
      -

      - -
      -
      - - - - - - query("SHOW TABLE STATUS LIKE '$table'"); - - if ($conn->isResultSet($infoSql) == 1) { - - $infoRow = $conn->fetchAssoc($infoSql); - - echo ""; - echo ""; - echo ""; - echo ""; - - } - } - - echo ''; - echo ''; - echo ''; - echo ''; - - ?> -
      - : - - -
      "; - echo __("Charset") . ":"; - echo ""; - echo ""; - echo "
      '; - echo ''; - echo '
      -
      -
      - - query("SHOW INDEX FROM `$table`"); - - if ($conn->isResultSet($indexListSQL)) { - - ?> - -
      - - - - - -
      - - ' . __("Indexes") . '    '; - - echo __("Select") . ':  ' . __("All") . '  ' . __("None") . ''; - echo '     ' . __("With selected") . ':  ' . __("Delete") . ''; - - ?> - -
      - - fetchAssoc($indexListSQL)) { - if (!array_key_exists($indexListRow['Key_name'], $indexList)) { - $indexList[$indexListRow['Key_name']] = $indexListRow['Column_name']; - } else { - $indexList[$indexListRow['Key_name']] .= ", " . $indexListRow['Column_name']; - } - } - - echo '
      '; - - echo '
       
      '; - - echo '
      '; - echo '
      '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      ' . __("Key") . '
      ' . __("Columns") . '
      '; - echo '
      '; - echo '
      '; - - echo '
      '; - - $m = 0; - - foreach ($indexList as $keyName => $columns) { - echo '
      '; - } - - echo '
      '; - - echo '
      '; - - $m = 0; - - foreach ($indexList as $keyName => $columns) { - echo '
      '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      ' . $keyName . '
      ' . $columns . '
      '; - echo '
      '; - - - $m++; - } - - echo '
      '; - echo '
      '; - - $m++; - - } - - ?> - -
      -

      -
      -
      - - - - - - - - - - - - - -
      - : - - -
      - : - - ' . $fieldList[$i] . '
      '; - } - - if (count($fieldList) > 5) { - echo '' . sprintf(__("Show %d more..."), count($fieldList) - 5) . ''; - echo ''; - } - - ?> -
      - " /> -
      -
      -
      -
      - -
      -
      - -

      - -
      -
      -
      - -
      - - query("SHOW TABLE STATUS LIKE '$table'"); - - if ($conn->isResultSet($infoSql) == 1) { - - $infoRow = $conn->fetchAssoc($infoSql); - - ?> - -

      -
      - ' . __("Storage engine") . ':
      ' . $engine . '
      '; - - if (array_key_exists('Collation', $infoRow) && isset($collationList) && array_key_exists($infoRow['Collation'], $collationList)) { - echo '
      ' . ("Charset") . ':
      ' . $collationList[$infoRow['Collation']] . '
      '; - } - - echo '
      ' . __("Rows") . ':
      ' . number_format($infoRow['Rows']) . '
      '; - echo '
      ' . __("Size") . ':
      ' . memoryFormat($infoRow['Data_length']) . '
      '; - echo '
      ' . __("Overhead") . ':
      ' . memoryFormat($infoRow['Data_free']) . '
      '; - echo '
      ' . __("Auto Increment") . ':
      ' . number_format($infoRow['Auto_increment']) . '
      '; - - ?> -
      -
      - - - - - -
      -
      - -getAdapter() == "sqlite" && sizeof($structureSql) > 0) { - -?> - - - - - -
      - - - - - -
      - - ' . __("Columns") . ''; - - ?> - -
      - - '; - - echo '
      '; - echo '
      '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      ' . __("Name") . '
      ' . __("Type") . '
      '; - echo '
      '; - echo '
      '; - - echo '
      '; - - $m = 0; - - foreach ($structureSql as $column) { - - echo '
      '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      ' . $column[0] . '
      ' . $column[1] . '
      '; - echo '
      '; - - $fieldList[] = $column[0]; - - $m++; - } - - echo '
      '; - echo ''; - - if (version_compare($conn->getVersion(), "3.1.3", ">")) { - - ?> - -
      -

      - -
      - - - - - - - - - - - - - - - - - - - - -
      - : - - - - : - - -
      - : - - - - : - - -
      - : - - - -
      - " /> -
      -
      -
      - -
      -

      - -
      -
      - - - - - - - - - -
      - : - - -
      - " /> -
      -
      -
      - - - -
      -
      - -

      - -
      -
      -
      -
      - - tableRowCount($table); - - ?> - -

      -
      - ' . __("Rows") . ':
      ' . number_format($rowCount) . '
      '; - - ?> -
      -
      - - - -
      -
      - - - -
      -

      -

      -
      - - + +*/ + +include "functions.php"; + +loginCheck(); + +requireDatabaseAndTableBeDefined(); + +if (isset($db)) + $conn->selectDB($db); + +if (isset($_POST)) { + + // process form - add index + if (isset($_POST['INDEXTYPE'])) + $indexType = $_POST['INDEXTYPE']; + + if (isset($_POST['INDEXCOLUMNLIST'])) + $indexColumnList = $_POST['INDEXCOLUMNLIST']; + + if (isset($indexType) && isset($indexColumnList) && $indexType && $indexColumnList) { + $indexColumnList = implode("`, `", $indexColumnList); + + $indexQuery = "ALTER TABLE `$table` ADD "; + + if ($indexType == "INDEX") + $indexQuery .= "INDEX"; + else if ($indexType == "UNIQUE") + $indexQuery .= "UNIQUE"; + + $indexQuery .= " (`" . $indexColumnList . "`)"; + + $conn->query($indexQuery) or ($dbError = $conn->error()); + } + + ?> + + + + query($query) or ($dbError = $conn->error()); + } +} + +if (isset($dbError)) { + echo '
      ' . __("Error performing operation") . '

      ' . $dbError . '

      '; +} + +$structureSql = $conn->describeTable($table); + +if ($conn->getAdapter() == "mysql" && $conn->isResultSet($structureSql)) { + +?> + + + + + + +
      + + + + + +
      + + ' . __("Columns") . '    '; + + echo __("Select") . ':  ' . __("All") . '  ' . __("None") . ''; + echo '     ' . __("With selected") . ':  ' . __("Edit") . '  ' . __("Delete") . ''; + + ?> + +
      + + '; + + echo '
       
      '; + + echo '
      '; + echo '
      '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
      ' . __("Name") . '
      ' . __("Type") . '
      ' . __("Default") . '
      '; + echo '
      '; + echo '
      '; + + echo '
      '; + + $m = 0; + + while ($structureRow = $conn->fetchAssoc($structureSql)) { + echo '
      '; + } + + echo '
      '; + + $structureSql = $conn->describeTable($table); + + echo '
      '; + + $m = 0; + + while ($structureRow = $conn->fetchAssoc($structureSql)) { + + echo '
      '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
      ' . $structureRow['Field'] . '
      ' . $structureRow['Type'] . '
      ' . $structureRow['Default'] . '
      '; + echo '
      '; + + $fieldList[] = $structureRow['Field']; + + $m++; + } + + echo '
      '; + echo ''; + + ?> + +
      +

      + +
      + + + + + + + + + + + + + + + + + + + + + "; + echo __("Charset") . ":"; + echo ""; + echo ""; + } else { + echo ""; + echo ""; + } + + ?> + + + + + + + + + +
      + : + + + + : + + +
      + : + + + + : + + +
      + : + + + "; + echo ""; + echo "
      + : + + + + + +
      + :   + + " /> +
      +
      +
      + +
      +

      + +
      +
      + + + + + + query("SHOW TABLE STATUS LIKE '$table'"); + + if ($conn->isResultSet($infoSql) == 1) { + + $infoRow = $conn->fetchAssoc($infoSql); + + echo ""; + echo ""; + echo ""; + echo ""; + + } + } + + echo ''; + echo ''; + echo ''; + echo ''; + + ?> +
      + : + + +
      "; + echo __("Charset") . ":"; + echo ""; + echo ""; + echo "
      '; + echo ''; + echo '
      +
      +
      + + query("SHOW INDEX FROM `$table`"); + + if ($conn->isResultSet($indexListSQL)) { + + ?> + +
      + + + + + +
      + + ' . __("Indexes") . '    '; + + echo __("Select") . ':  ' . __("All") . '  ' . __("None") . ''; + echo '     ' . __("With selected") . ':  ' . __("Delete") . ''; + + ?> + +
      + + fetchAssoc($indexListSQL)) { + if (!array_key_exists($indexListRow['Key_name'], $indexList)) { + $indexList[$indexListRow['Key_name']] = $indexListRow['Column_name']; + } else { + $indexList[$indexListRow['Key_name']] .= ", " . $indexListRow['Column_name']; + } + } + + echo '
      '; + + echo '
       
      '; + + echo '
      '; + echo '
      '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
      ' . __("Key") . '
      ' . __("Columns") . '
      '; + echo '
      '; + echo '
      '; + + echo '
      '; + + $m = 0; + + foreach ($indexList as $keyName => $columns) { + echo '
      '; + } + + echo '
      '; + + echo '
      '; + + $m = 0; + + foreach ($indexList as $keyName => $columns) { + echo '
      '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
      ' . $keyName . '
      ' . $columns . '
      '; + echo '
      '; + + + $m++; + } + + echo '
      '; + echo '
      '; + + $m++; + + } + + ?> + +
      +

      +
      +
      + + + + + + + + + + + + + +
      + : + + +
      + : + + ' . $fieldList[$i] . '
      '; + } + + if (count($fieldList) > 5) { + echo '' . sprintf(__("Show %d more..."), count($fieldList) - 5) . ''; + echo ''; + } + + ?> +
      + " /> +
      +
      +
      +
      + +
      +
      + +

      + +
      +
      +
      + +
      + + query("SHOW TABLE STATUS LIKE '$table'"); + + if ($conn->isResultSet($infoSql) == 1) { + + $infoRow = $conn->fetchAssoc($infoSql); + + ?> + +

      +
      + ' . __("Storage engine") . ':
      ' . $engine . '
      '; + + if (array_key_exists('Collation', $infoRow) && isset($collationList)) { + echo '
      ' . ("Charset") . ':
      ' . $collationList[$infoRow['Collation']] . '
      '; + } + + echo '
      ' . __("Rows") . ':
      ' . number_format($infoRow['Rows']) . '
      '; + echo '
      ' . __("Size") . ':
      ' . memoryFormat($infoRow['Data_length']) . '
      '; + echo '
      ' . __("Overhead") . ':
      ' . memoryFormat($infoRow['Data_free']) . '
      '; + echo '
      ' . __("Auto Increment") . ':
      ' . number_format($infoRow['Auto_increment']) . '
      '; + + ?> +
      +
      + + + + + +
      +
      + +getAdapter() == "sqlite" && sizeof($structureSql) > 0) { + +?> + + + + + +
      + + + + + +
      + + ' . __("Columns") . ''; + + ?> + +
      + + '; + + echo '
      '; + echo '
      '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
      ' . __("Name") . '
      ' . __("Type") . '
      '; + echo '
      '; + echo '
      '; + + echo '
      '; + + $m = 0; + + foreach ($structureSql as $column) { + + echo '
      '; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
      ' . $column[0] . '
      ' . $column[1] . '
      '; + echo '
      '; + + $fieldList[] = $column[0]; + + $m++; + } + + echo '
      '; + echo ''; + + if (version_compare($conn->getVersion(), "3.1.3", ">")) { + + ?> + +
      +

      + +
      + + + + + + + + + + + + + + + + + + + + +
      + : + + + + : + + +
      + : + + + + : + + +
      + : + + + +
      + " /> +
      +
      +
      + +
      +

      + +
      +
      + + + + + + + + + +
      + : + + +
      + " /> +
      +
      +
      + + + +
      +
      + +

      + +
      +
      +
      +
      + + tableRowCount($table); + + ?> + +

      +
      + ' . __("Rows") . ':
      ' . number_format($rowCount) . '
      '; + + ?> +
      +
      + + + +
      +
      + + + +
      +

      +

      +
      + + \ No newline at end of file diff --git a/htdocs/sqlbuddy/themes/bittersweet/css/ie.css b/htdocs/sqlbuddy/themes/bittersweet/css/ie.css index 7965211c3..b0e6c8782 100755 --- a/htdocs/sqlbuddy/themes/bittersweet/css/ie.css +++ b/htdocs/sqlbuddy/themes/bittersweet/css/ie.css @@ -1,44 +1,44 @@ -#header { -padding-bottom: 4px; -} - -#rightside { -padding-bottom: 0 !important; -} - -.leftchecks { -margin-left: -22px !important; -} -.browsetab .leftchecks { -margin-left: -38px !important; -} - -.manip { -padding-top: 0 !important; -padding-bottom: 1px !important; -} -.manip dt { -padding: 0 5px 0 1px !important; -} - -.browsetab .gridheader, .users .gridheader { -margin-top: -15px; -} - -.dblist { -float: none !important; -} -.dblist ul li { -float: none !important; -} - -.sublist { -width: 225px; -} - -#leftside { -width: 225px !important; -} -#rightside { -margin-left: 225px !important; +#header { +padding-bottom: 4px; +} + +#rightside { +padding-bottom: 0 !important; +} + +.leftchecks { +margin-left: -22px !important; +} +.browsetab .leftchecks { +margin-left: -38px !important; +} + +.manip { +padding-top: 0 !important; +padding-bottom: 1px !important; +} +.manip dt { +padding: 0 5px 0 1px !important; +} + +.browsetab .gridheader, .users .gridheader { +margin-top: -15px; +} + +.dblist { +float: none !important; +} +.dblist ul li { +float: none !important; +} + +.sublist { +width: 225px; +} + +#leftside { +width: 225px !important; +} +#rightside { +margin-left: 225px !important; } \ No newline at end of file diff --git a/htdocs/sqlbuddy/themes/bittersweet/css/main.css b/htdocs/sqlbuddy/themes/bittersweet/css/main.css index 4937196e9..dd69ca055 100755 --- a/htdocs/sqlbuddy/themes/bittersweet/css/main.css +++ b/htdocs/sqlbuddy/themes/bittersweet/css/main.css @@ -1,155 +1,155 @@ -body { -background: rgb(255, 255, 255) url(../images/initLoad-dark.png) no-repeat 50% 125px; -} - -#header { -background: rgb(80, 80, 80) url(../images/header.png) repeat-x; -} - -#headerlogo { -width: 185px !important; -} -#leftside { -width: 205px !important; -overflow-y: hidden; -} -#rightside { -margin-left: 205px !important; -} -#sidemenu { -overflow-x: hidden; -} - -#bottom { -background: transparent url(../../../images/window-shadow-bottom.png) repeat-x scroll 0px -7px; -} - -#innercontent a { -color: steelBlue; -} -#innercontent a:hover { -color: rgb(50, 50, 50); -} - -h3, h4 { -color: rgb(135, 135, 115); -text-transform: uppercase; -font-weight: normal; -} -h3 { -font-size: 12px; -} -h4 { -border-bottom: 1px solid rgb(210, 210, 210); -line-height: 1.3; -font-size: 14px; -} - -#headerinfo a { -color: rgb(200, 200, 200) !important; -text-decoration: none; -} -#headerinfo a:hover { -color: rgb(250, 250, 250) !important; -} - -.grid { -border-color: rgb(220, 220, 220) rgb(190, 190, 190) rgb(190, 190, 190) rgb(190, 190, 190); -} - -.alternator { -border-bottom-color: transparent; -background: white; -} -.alternator2 { -background: rgb(245, 245, 245); -} -.highlighted { -border-bottom-color: rgb(210, 210, 210) !important; -background: rgb(230, 230, 215) !important; -} - -.paginator a { -color: rgb(125, 125, 125) !important; -} - -.dblistheader { -color: rgb(150, 150, 150) !important; -} -.dblist { -float: left; -} -.dblist ul li { -float: left; -clear: left; -} -.dblist ul li a { -display: inline !important; -border-width: 0 !important; -} -.dblist ul li a .menutext { -color: rgb(80, 80, 80); -margin-left: 0 !important; -float: left; -} -.dblist ul li a:hover .menutext { -color: rgb(40, 40, 40); -} -.dblist ul li a .menuicon { -color: rgb(150, 150, 150) !important; -} -.dblist ul li.selected>a { -font-weight: bold; -} -.sublist { -float: left; -clear: left; -line-height: 18px; -} -.sublist li a { -color: rgb(80, 80, 80); -} -.sublist li a:hover { -color: rgb(40, 40, 40); -} -.subcount { -color: rgb(150, 150, 150); -} - -#loginform { -padding: 3px; -border: 1px solid rgb(200, 200, 200); -} -#loginform .loginspacer { -background: #E9EBDF !important; -padding: 10px 15px 10px 11px !important; -} -.loginheader { -border-bottom-color: rgb(200, 200, 200); -} -#loginform .field { -color: #777; -} - -#toptabs ul li a { -color: rgb(220, 220, 220); -} -#toptabs ul li a .rowcount { -color: rgb(175, 175, 175); -} -#toptabs ul li a:hover { -color: rgb(250, 250, 250); -} -#toptabs ul li.selected a { -color: rgb(250, 250, 250); -font-weight: bold; -} -#toptabs ul li.selected a .rowcount { -color: rgb(225, 225, 225); -} -#toptabs ul li.deactivated a { -color: rgb(135, 135, 135) !important; -} -#toptabs ul li.deactivated a .rowcount { -color: rgb(175, 175, 175) !important; +body { +background: rgb(255, 255, 255) url(../images/initLoad-dark.png) no-repeat 50% 125px; +} + +#header { +background: rgb(80, 80, 80) url(../images/header.png) repeat-x; +} + +#headerlogo { +width: 185px !important; +} +#leftside { +width: 205px !important; +overflow-y: hidden; +} +#rightside { +margin-left: 205px !important; +} +#sidemenu { +overflow-x: hidden; +} + +#bottom { +background: transparent url(../../../images/window-shadow-bottom.png) repeat-x scroll 0px -7px; +} + +#innercontent a { +color: steelBlue; +} +#innercontent a:hover { +color: rgb(50, 50, 50); +} + +h3, h4 { +color: rgb(135, 135, 115); +text-transform: uppercase; +font-weight: normal; +} +h3 { +font-size: 12px; +} +h4 { +border-bottom: 1px solid rgb(210, 210, 210); +line-height: 1.3; +font-size: 14px; +} + +#headerinfo a { +color: rgb(200, 200, 200) !important; +text-decoration: none; +} +#headerinfo a:hover { +color: rgb(250, 250, 250) !important; +} + +.grid { +border-color: rgb(220, 220, 220) rgb(190, 190, 190) rgb(190, 190, 190) rgb(190, 190, 190); +} + +.alternator { +border-bottom-color: transparent; +background: white; +} +.alternator2 { +background: rgb(245, 245, 245); +} +.highlighted { +border-bottom-color: rgb(210, 210, 210) !important; +background: rgb(230, 230, 215) !important; +} + +.paginator a { +color: rgb(125, 125, 125) !important; +} + +.dblistheader { +color: rgb(150, 150, 150) !important; +} +.dblist { +float: left; +} +.dblist ul li { +float: left; +clear: left; +} +.dblist ul li a { +display: inline !important; +border-width: 0 !important; +} +.dblist ul li a .menutext { +color: rgb(80, 80, 80); +margin-left: 0 !important; +float: left; +} +.dblist ul li a:hover .menutext { +color: rgb(40, 40, 40); +} +.dblist ul li a .menuicon { +color: rgb(150, 150, 150) !important; +} +.dblist ul li.selected>a { +font-weight: bold; +} +.sublist { +float: left; +clear: left; +line-height: 18px; +} +.sublist li a { +color: rgb(80, 80, 80); +} +.sublist li a:hover { +color: rgb(40, 40, 40); +} +.subcount { +color: rgb(150, 150, 150); +} + +#loginform { +padding: 3px; +border: 1px solid rgb(200, 200, 200); +} +#loginform .loginspacer { +background: #E9EBDF !important; +padding: 10px 15px 10px 11px !important; +} +.loginheader { +border-bottom-color: rgb(200, 200, 200); +} +#loginform .field { +color: #777; +} + +#toptabs ul li a { +color: rgb(220, 220, 220); +} +#toptabs ul li a .rowcount { +color: rgb(175, 175, 175); +} +#toptabs ul li a:hover { +color: rgb(250, 250, 250); +} +#toptabs ul li.selected a { +color: rgb(250, 250, 250); +font-weight: bold; +} +#toptabs ul li.selected a .rowcount { +color: rgb(225, 225, 225); +} +#toptabs ul li.deactivated a { +color: rgb(135, 135, 135) !important; +} +#toptabs ul li.deactivated a .rowcount { +color: rgb(175, 175, 175) !important; } \ No newline at end of file diff --git a/htdocs/sqlbuddy/themes/classic/css/ie.css b/htdocs/sqlbuddy/themes/classic/css/ie.css index 3af70b392..749d8557b 100755 --- a/htdocs/sqlbuddy/themes/classic/css/ie.css +++ b/htdocs/sqlbuddy/themes/classic/css/ie.css @@ -1,31 +1,31 @@ -#header { -padding-bottom: 4px; -} - -#rightside { -padding-bottom: 0 !important; -} - -.leftchecks { -margin-left: -22px !important; -} -.browsetab .leftchecks { -margin-left: -38px !important; -} - -.manip { -padding-top: 0 !important; -padding-bottom: 1px !important; -} -.manip dt { -padding: 0 5px 0 1px !important; -} - -.browsetab .gridheader, .users .gridheader { -margin-top: -15px; -} - -.sublist li a { -padding-top: 0 !important; -padding-bottom: 1px !important; +#header { +padding-bottom: 4px; +} + +#rightside { +padding-bottom: 0 !important; +} + +.leftchecks { +margin-left: -22px !important; +} +.browsetab .leftchecks { +margin-left: -38px !important; +} + +.manip { +padding-top: 0 !important; +padding-bottom: 1px !important; +} +.manip dt { +padding: 0 5px 0 1px !important; +} + +.browsetab .gridheader, .users .gridheader { +margin-top: -15px; +} + +.sublist li a { +padding-top: 0 !important; +padding-bottom: 1px !important; } \ No newline at end of file diff --git a/htdocs/sqlbuddy/themes/classic/css/main.css b/htdocs/sqlbuddy/themes/classic/css/main.css index ad4b781b6..109923426 100755 --- a/htdocs/sqlbuddy/themes/classic/css/main.css +++ b/htdocs/sqlbuddy/themes/classic/css/main.css @@ -1,111 +1,111 @@ -html { -background: rgb(125, 125, 125) url(../images/shading.png); -} - -#header { -background: url(../images/header.png) repeat-x bottom; -border-bottom: 1px solid rgb(150, 150, 150); -} - -h3, h4 { -color: steelblue; -} - -#innercontent { -background: white; -border-color: rgb(75, 75, 75); -border-width: 0 2px; -border-style: solid; -} - -.corners { -background: rgb(75, 75, 75); -height: 2px; -} -.corners div { -width: 4px; -height: 4px; -background-repeat: no-repeat; -} -.tl { -background: url(../images/corner-tl.png); -float: left; -} -.tr { -background: url(../images/corner-tr.png); -float: right; -} -.bl { -background: url(../images/corner-bl.png); -float: left; -margin-top: -2px; -} -.br { -background: url(../images/corner-br.png); -float: right; -margin-top: -2px; -} - -#headerinfo a { -color: rgb(215, 215, 215) !important; -text-shadow: rgb(50, 50, 50) 0 1px 0; -} -#headerinfo a:hover { -color: #fff !important; -} - -#loginform { -padding: 7px; -background: url(../../../images/transparent.png); -} -#loginform .loginspacer { -background: white; -} - -.dblistheader { -color: rgb(220, 220, 220); -text-shadow: rgb(75, 75, 75) 0px 1px 0px; -} - -.dblist ul li a .menutext { -color: #fff; -} -.dblist ul li a .menuicon { -color: rgb(220, 220, 220); -} -.dblist ul li.selected>a { -background: rgb(90, 90, 90) !important; -border-color: rgb(70, 70, 70); -} -.sublist li a { -color: #fff; -} -.subcount { -color: rgb(200, 200, 200); -} - -#toptabs ul li a { -color: rgb(215, 215, 215); -text-shadow: rgb(50, 50, 50) 0 1px 0; -font-weight: bold; -} -#toptabs ul li a .rowcount { -color: rgb(235, 235, 235); -} -#toptabs ul li a:hover { -color: #fff; -} -#toptabs ul li.selected a { -color: #fff; -font-weight: bold; -text-shadow: rgb(50, 50, 50) 0 1px 0; -} -#toptabs ul li.selected a .rowcount { -color: rgb(235, 235, 235); -} -#toptabs ul li.deactivated a { -color: rgb(175, 175, 175) !important; -} -#toptabs ul li.deactivated a .rowcount { -color: rgb(175, 175, 175) !important; +html { +background: rgb(125, 125, 125) url(../images/shading.png); +} + +#header { +background: url(../images/header.png) repeat-x bottom; +border-bottom: 1px solid rgb(150, 150, 150); +} + +h3, h4 { +color: steelblue; +} + +#innercontent { +background: white; +border-color: rgb(75, 75, 75); +border-width: 0 2px; +border-style: solid; +} + +.corners { +background: rgb(75, 75, 75); +height: 2px; +} +.corners div { +width: 4px; +height: 4px; +background-repeat: no-repeat; +} +.tl { +background: url(../images/corner-tl.png); +float: left; +} +.tr { +background: url(../images/corner-tr.png); +float: right; +} +.bl { +background: url(../images/corner-bl.png); +float: left; +margin-top: -2px; +} +.br { +background: url(../images/corner-br.png); +float: right; +margin-top: -2px; +} + +#headerinfo a { +color: rgb(215, 215, 215) !important; +text-shadow: rgb(50, 50, 50) 0 1px 0; +} +#headerinfo a:hover { +color: #fff !important; +} + +#loginform { +padding: 7px; +background: url(../../../images/transparent.png); +} +#loginform .loginspacer { +background: white; +} + +.dblistheader { +color: rgb(220, 220, 220); +text-shadow: rgb(75, 75, 75) 0px 1px 0px; +} + +.dblist ul li a .menutext { +color: #fff; +} +.dblist ul li a .menuicon { +color: rgb(220, 220, 220); +} +.dblist ul li.selected>a { +background: rgb(90, 90, 90) !important; +border-color: rgb(70, 70, 70); +} +.sublist li a { +color: #fff; +} +.subcount { +color: rgb(200, 200, 200); +} + +#toptabs ul li a { +color: rgb(215, 215, 215); +text-shadow: rgb(50, 50, 50) 0 1px 0; +font-weight: bold; +} +#toptabs ul li a .rowcount { +color: rgb(235, 235, 235); +} +#toptabs ul li a:hover { +color: #fff; +} +#toptabs ul li.selected a { +color: #fff; +font-weight: bold; +text-shadow: rgb(50, 50, 50) 0 1px 0; +} +#toptabs ul li.selected a .rowcount { +color: rgb(235, 235, 235); +} +#toptabs ul li.deactivated a { +color: rgb(175, 175, 175) !important; +} +#toptabs ul li.deactivated a .rowcount { +color: rgb(175, 175, 175) !important; } \ No newline at end of file diff --git a/htdocs/sqlbuddy/users.php b/htdocs/sqlbuddy/users.php index 910a68a5d..8902eb9b4 100755 --- a/htdocs/sqlbuddy/users.php +++ b/htdocs/sqlbuddy/users.php @@ -1,440 +1,440 @@ - - -*/ - -include "functions.php"; - -loginCheck(); - -function removeAdminPrivs($priv) { - if ($priv == "FILE" || $priv == "PROCESS" || $priv == "RELOAD" || $priv == "SHUTDOWN" || $priv == "SUPER") - return false; - else - return true; -} - -if ($_POST) { - - if (isset($_POST['NEWHOST'])) - $newHost = $_POST['NEWHOST']; - else - $newHost = "localhost"; - - if (isset($_POST['NEWNAME'])) - $newName = $_POST['NEWNAME']; - - if (isset($_POST['NEWPASS'])) - $newPass = $_POST['NEWPASS']; - - if (isset($_POST['ACCESSLEVEL'])) - $accessLevel = $_POST['ACCESSLEVEL']; - else - $accessLevel = "GLOBAL"; - - if ($accessLevel != "LIMITED") - $accessLevel = "GLOBAL"; - - if (isset($_POST['DBLIST'])) - $dbList = $_POST['DBLIST']; - else - $dbList = array(); - - if (isset($_POST['NEWCHOICE'])) - $newChoice = $_POST['NEWCHOICE']; - - if (isset($_POST['NEWPRIVILEGES'])) - $newPrivileges = $_POST['NEWPRIVILEGES']; - - if (isset($newName) && ($accessLevel == "GLOBAL" || ($accessLevel == "LIMITED" && sizeof($dbList) > 0))) { - - if ($newChoice == "ALL") { - $privList = "ALL"; - } else { - - if (sizeof($newPrivileges) > 0) { - if ($accessLevel == "LIMITED") { - $newPrivileges = array_filter($newPrivileges, "removeAdminPrivs"); - } - - $privList = implode(", ", $newPrivileges); - - } else { - $privList = "USAGE"; - } - } - - if ($accessLevel == "LIMITED") { - foreach ($dbList as $theDb) { - $newQuery = "GRANT " . $privList; - - $newQuery .= " ON `$theDb`.*"; - - $newQuery .= " TO '" . $newName . "'@'" . $newHost . "'"; - - if ($newPass) - $newQuery .= " IDENTIFIED BY '" . $newPass . "'"; - - if (isset($_POST['GRANTOPTION'])) - $newQuery .= " WITH GRANT OPTION"; - - $conn->query($newQuery) or ($dbError = $conn->error()); - } - } else { - $newQuery = "GRANT " . $privList; - - $newQuery .= " ON *.*"; - - $newQuery .= " TO '" . $newName . "'@'" . $newHost . "'"; - - if ($newPass) - $newQuery .= " IDENTIFIED BY '" . $newPass . "'"; - - if (isset($_POST['GRANTOPTION'])) - $newQuery .= " WITH GRANT OPTION"; - - $conn->query($newQuery) or ($dbError = $conn->error()); - } - - $conn->query("FLUSH PRIVILEGES") or ($dbError = $conn->error()); - - } -} - -$connected = $conn->selectDB("mysql"); - -// delete users -if (isset($_POST['deleteUsers']) && $connected) { - $deleteUsers = $_POST['deleteUsers']; - - // boom! - $userList = explode(";", $deleteUsers); - - foreach ($userList as $each) { - $split = explode("@", $each, 2); - - if (isset($split[0])) - $user = trim($split[0]); - - if (isset($split[1])) - $host = trim($split[1]); - - if (isset($user) && isset($host)) { - $conn->query("REVOKE ALL PRIVILEGES ON *.* FROM '$user'@'$host'"); - $conn->query("REVOKE GRANT OPTION ON *.* FROM '$user'@'$host'"); - $conn->query("DELETE FROM `user` WHERE `User`='$user' AND `Host`='$host'"); - $conn->query("DELETE FROM `db` WHERE `User`='$user' AND `Host`='$host'"); - $conn->query("DELETE FROM `tables_priv` WHERE `User`='$user' AND `Host`='$host'"); - $conn->query("DELETE FROM `columns_priv` WHERE `User`='$user' AND `Host`='$host'"); - } - } - $conn->query("FLUSH PRIVILEGES"); -} - -if (isset($dbError)) { - echo '
      '; - echo '' . __("Error performing operation") . '

      ' . $dbError . '

      '; - echo '
      '; -} - -?> - -
      - -query("SELECT * FROM `user`"); - - if ($conn->isResultSet($userSql)) { - - ?> - - - - - -
      - ' . __("All") . '  ' . __("None") . ''; - echo '     ' . __("With selected") . ':  ' . __("Edit") . '  ' . __("Delete") . ''; - - ?> - -
      - - '; - - echo '
       
      '; - - echo '
      '; - echo '
      '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      ' . __("Host") . '
      ' . __("User") . '
      '; - echo '
      '; - echo '
      '; - - echo '
      '; - - $m = 0; - - while ($userRow = $conn->fetchAssoc($userSql)) { - $queryBuilder = $userRow['User'] . "@" . $userRow['Host']; - echo '
      '; - } - - echo '
      '; - - $userSql = $conn->query("SELECT * FROM `user`"); - - echo '
      '; - - if ($conn->isResultSet($userSql)) { - $m = 0; - - while ($userRow = $conn->fetchAssoc($userSql)) { - - echo '
      '; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo '
      ' . $userRow['Host'] . '
      ' . $userRow['User'] . '
      '; - echo '
      '; - - $m++; - } - } - - echo '
      '; - echo '
      '; - - } - - $hasPermissions = false; - - // check to see if this user has proper permissions to manage users - $checkSql = $conn->query("SELECT `Grant_priv` FROM `user` WHERE `Host`='" . $conn->getOptionValue("host") . "' AND `User`='" . $_SESSION['SB_LOGIN_USER'] . "' LIMIT 1"); - - if ($conn->isResultSet($checkSql)) { - $grantValue = $conn->result($checkSql, 0, "Grant_priv"); - - if ($grantValue == "Y") { - $hasPermissions = true; - } - } - - if ($hasPermissions) { - - ?> - -
      -

      - -
      - - - - - - - - - - - - - - listDatabases(); - - if ($conn->isResultSet($dbList)) { - - ?> - - - - - - - - - -
      :
      :
      :
      : -
      - - - - -
      : -
      - - - - -
      - - - - - - -
      : - -
      - -
      - " /> -
      -
      -
      - -

      -

      - -
      -

      -

      -
      - - - - \ No newline at end of file