Permalink
Browse files

Small tweaks and such (related to gzip, sqlite).

  • Loading branch information...
1 parent 11383ef commit cec2daaa3a072431af52e75606c9474d02b85153 calvinlough committed Sep 7, 2008
Showing with 71 additions and 49 deletions.
  1. +1 −1 README
  2. +9 −0 config.php
  3. +11 −1 dboverview.php
  4. +22 −2 includes/class/Sql-php4.php
  5. +3 −6 includes/common.php
  6. +3 −3 js/helpers.js
  7. +22 −36 serve.php
View
2 README
@@ -33,7 +33,7 @@ unzip the new version in its place.
TRANSLATIONS
-SQL Buddy now has an online translation page. It allows a group
+SQL Buddy now has an online hub for translations. It allows a group
of people to collaborate together on a translation. The address is
http://www.sqlbuddy.com/translations/. If you have any questions about working
on a translation, feel free to contact me using the form on the website.
View
@@ -53,4 +53,13 @@
$sbconfig['RowsPerPage'] = 100;
+/*
+* When set to true, the server will attempt to compress all content before it is sent to the
+* browser. This includes css and javascript files as well as html content. 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;
+
?>
View
@@ -552,7 +552,17 @@
<td colspan="3">
<label><input type="checkbox" name="NOTNULL" onchange="updateFieldName(this)"><?php echo __("Not Null"); ?></label>
<label><input type="checkbox" name="UNIQUE" onchange="updateFieldName(this)"><?php echo __("Unique"); ?></label>
- <label><input type="checkbox" name="AUTO" onchange="updateFieldName(this)"><?php echo __("Auto Increment"); ?></label>
+ <?php
+
+ // autoincrement supported in SQLite 3+
+ if (version_compare($conn->getVersion(), "3.0.0", ">="))
+ {
+ ?>
+ <label><input type="checkbox" name="AUTO" onchange="updateFieldName(this)"><?php echo __("Auto Increment"); ?></label>
+ <?php
+ }
+
+ ?>
</td>
</tr>
<?php
@@ -90,7 +90,7 @@ function getAdapter()
function getMethod()
{
- return $this->adapter;
+ return $this->method;
}
function getOptionValue($optKey)
@@ -173,9 +173,20 @@ function rowCount($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")
@@ -191,6 +202,9 @@ function fetchArray($resultSet)
function fetchAssoc($resultSet)
{
+ if (!$resultSet)
+ return false;
+
if ($this->conn)
{
if ($this->method == "mysql")
@@ -206,6 +220,9 @@ function fetchAssoc($resultSet)
function affectedRows($resultSet)
{
+ if (!$resultSet)
+ return false;
+
if ($this->conn)
{
if ($this->method == "mysql")
@@ -221,6 +238,9 @@ function affectedRows($resultSet)
function result($resultSet, $targetRow, $targetColumn = "")
{
+ if (!$resultSet)
+ return false;
+
if ($this->conn)
{
if ($this->method == "mysql")
View
@@ -14,7 +14,6 @@
*/
error_reporting(E_ALL);
-ini_set('display_errors', 1);
if (!session_id())
session_start();
@@ -27,13 +26,9 @@
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.0");
define("PREVIEW_CHAR_SIZE", 65);
@@ -231,9 +226,11 @@ function validateRequest()
function startOutput()
{
+ global $sbconfig;
+
if (!headers_sent())
{
- if (extension_loaded("zlib") && !ini_get("zlib.output_compression") && ini_get("output_handler") != "ob_gzhandler")
+ if (extension_loaded("zlib") && isset($sbconfig['EnableGzip']) && $sbconfig['EnableGzip'] == true && !ini_get("zlib.output_compression") && ini_get("output_handler") != "ob_gzhandler")
{
ob_start("ob_gzhandler");
header("Content-Encoding: gzip");
View
@@ -210,17 +210,17 @@ function finishTabLoad(responseText)
var pageTitle;
if (sb.table)
{
- pageTitle = sb.getTabTitle(sb.topTab) + " " + "-" + " " + sb.table;
+ pageTitle = sb.getTabTitle(sb.topTab) + " - " + sb.table;
}
else if (sb.db)
{
- pageTitle = sb.getTabTitle(sb.topTab) + " " + "-" + " " + sb.db;
+ pageTitle = sb.getTabTitle(sb.topTab) + " - " + sb.db;
}
else
{
pageTitle = sb.getTabTitle(sb.topTab);
}
- document.title = "SQL Buddy " + "-" + " " + pageTitle;
+ document.title = "SQL Buddy - " + pageTitle;
refreshRowCount();
}
View
@@ -13,8 +13,21 @@
*/
-function removeSpacesNewlinesCSS($input)
+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);
@@ -32,54 +45,27 @@ function removeSpacesNewlinesCSS($input)
return trim($input);
}
-function removeSpacesNewlinesJS($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(" + ", "+", $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);
}
-function compressCSS($input)
-{
- // remove comments
- $input = preg_replace("/\/\*.*\*\//Us", "", $input);
-
- $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);
-
- $input = removeSpacesNewlinesCSS($input);
-
- return $input;
-}
-
-function compressJS($input)
-{
-
- // remove comments
- $input = preg_replace("/\/\/.*\n/Us", "", $input);
- $input = preg_replace("/\/\*.*\*\//Us", "", $input);
-
- $input = removeSpacesNewlinesJS($input);
-
- return $input;
-}
-
if (isset($_GET['file']))
{
@@ -93,7 +79,7 @@ function compressJS($input)
if (file_exists($filename))
{
- if (extension_loaded('zlib'))
+ if (extension_loaded('zlib') && isset($sbconfig['EnableGzip']) && $sbconfig['EnableGzip'] == true)
{
ob_start("ob_gzhandler");
header("Content-Encoding: gzip");

0 comments on commit cec2daa

Please sign in to comment.