Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Modified the Background Grid. Easier on the eyes for larger projects. #1

Closed
wants to merge 3 commits into from

2 participants

@lucanos

Was regular 10px10px squares. Now has 100px100px and 50px*50px
intersections darkened.

lucanos added some commits
@lucanos lucanos Swapped Background Grid
Was regular 10px*10px squares. Now has 100px*100px and 50px*50px
intersections darkened.
de90e15
@lucanos lucanos Directing Readme to GitHub Page 61ef6e9
@lucanos lucanos Added MySQLi Functionality
Tests if MySQLi is available and, if so, uses that in preference over
MySQL.
358a69a
@ondras
Owner

Please remove those additional commits and open a new pull request with just the bg image change...

@ondras ondras closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 17, 2013
  1. @lucanos

    Swapped Background Grid

    lucanos authored
    Was regular 10px*10px squares. Now has 100px*100px and 50px*50px
    intersections darkened.
  2. @lucanos
  3. @lucanos

    Added MySQLi Functionality

    lucanos authored
    Tests if MySQLi is available and, if so, uses that in preference over
    MySQL.
This page is out of date. Refresh to see the latest.
View
2  README
@@ -1 +1 @@
-For documentation, visit http://code.google.com/p/wwwsqldesigner/w/list
+For documentation, visit http://lucanos.github.com/wwwsqldesigner/
View
269 backend/php-mysql/index.php
@@ -1,11 +1,14 @@
<?php
set_time_limit(0);
+
+ $mysqlconnection = false;
+ $usemysqli = function_exists( 'mysqli_connect' );
+
function setup_saveloadlist() {
define("SERVER","localhost");
define("USER","");
define("PASSWORD","");
- define("DB","home");
- define("TABLE","wwwsqldesigner");
+ define("DB","information_schema");
}
function setup_import() {
define("SERVER","localhost");
@@ -14,179 +17,215 @@ function setup_import() {
define("DB","information_schema");
}
function connect() {
- $conn = mysql_connect(SERVER,USER,PASSWORD);
- if (!$conn) return false;
- $res = mysql_select_db(DB);
- if (!$res) return false;
- return true;
+ global $mysqlconnection, $usemysqli;
+ if( function_exists( 'mysqli_connect' ) ){
+ return ( $mysqlconnection = mysqli_connect( SERVER , USER , PASSWORD , DB ) );
+ }else{
+ return ( ( $mysqlconnection = mysql_connect( SERVER , USER , PASSWORD ) )
+ && ( $res = mysql_select_db( DB ) ) );
+ }
+ }
+
+ function maybe_mysqli_real_escape_string( $string ){
+ global $mysqlconnection, $usemysqli;
+ return ( $usemysqli ? mysqli_real_escape_string( $mysqlconnection , $string ) : mysql_real_escape_string( $string ) );
+ }
+ function maybe_mysqli_query( $query ){
+ global $mysqlconnection, $usemysqli;
+ return ( $usemysqli ? mysqli_query( $mysqlconnection , $query ) : mysql_query( $query ) );
+ }
+ function maybe_mysqli_fetch_array( $result ){
+ global $usemysqli;
+ return ( $usemysqli ? mysqli_fetch_array( $result ) : mysql_fetch_array( $result ) );
+ }
+ function maybe_mysqli_fetch_assoc( $result ){
+ global $usemysqli;
+ return ( $usemysqli ? mysqli_fetch_assoc( $result ) : mysql_fetch_assoc( $result ) );
+ }
+ function maybe_mysqli_num_rows( $result ){
+ global $usemysqli;
+ return ( $usemysqli ? mysqli_num_rows( $result ) : mysql_num_rows( $result ) );
}
function import() {
- $db = (isset($_GET["database"]) ? $_GET["database"] : "information_schema");
- $db = mysql_real_escape_string($db);
- $xml = "";
+ global $mysqlconnection, $usemysqli;
+ $db = ( isset( $_GET['database'] ) ? $_GET['database'] : 'information_schema' );
+ $db = maybe_mysqli_real_escape_string( $db );
+ $xml = '';
$arr = array();
- @ $datatypes = file("../../db/mysql/datatypes.xml");
+ @ $datatypes = file( '../../db/mysql/datatypes.xml' );
$arr[] = $datatypes[0];
$arr[] = '<sql db="mysql">';
- for ($i=1;$i<count($datatypes);$i++) {
- $arr[] = $datatypes[$i];
- }
+ foreach( $datatypes as $d )
+ $arr[] = $d;
- $result = mysql_query("SELECT * FROM TABLES WHERE TABLE_SCHEMA = '".$db."'");
- while ($row = mysql_fetch_array($result)) {
- $table = $row["TABLE_NAME"];
- $xml .= '<table name="'.$table.'">';
- $comment = (isset($row["TABLE_COMMENT"]) ? $row["TABLE_COMMENT"] : "");
- if ($comment) { $xml .= '<comment>'.htmlspecialchars($comment).'</comment>'; }
-
- $q = "SELECT * FROM COLUMNS WHERE TABLE_NAME = '".$table."' AND TABLE_SCHEMA = '".$db."'";
- $result2 = mysql_query($q);
- while ($row = mysql_fetch_array($result2)) {
- $name = $row["COLUMN_NAME"];
- $type = $row["COLUMN_TYPE"];
- $comment = (isset($row["COLUMN_COMMENT"]) ? $row["COLUMN_COMMENT"] : "");
- $null = ($row["IS_NULLABLE"] == "YES" ? "1" : "0");
-
- if (preg_match("/binary/i",$row["COLUMN_TYPE"])) {
- $def = bin2hex($row["COLUMN_DEFAULT"]);
- } else {
- $def = $row["COLUMN_DEFAULT"];
- }
+ $query = 'SELECT * FROM TABLES WHERE TABLE_SCHEMA = `'.$db.'`';
+ $result = maybe_mysqli_query( $query );
- $ai = (preg_match("/auto_increment/i",$row["EXTRA"]) ? "1" : "0");
- if ($def == "NULL") { $def = ""; }
+ while( $row = maybe_mysqli_fetch_array( $result ) ){
+ $table = $row['TABLE_NAME'];
+ $xml .= '<table name="'.$table.'">';
+ $comment = ( isset( $row['TABLE_COMMENT'] ) ? $row['TABLE_COMMENT'] : '' );
+ if( $comment )
+ $xml .= '<comment>'.htmlspecialchars( $comment ).'</comment>';
+
+ $query = 'SELECT * FROM COLUMNS WHERE TABLE_NAME = `'.$table.'` AND TABLE_SCHEMA = `'.$db.'`';
+ $result2 = maybe_mysqli_query( $query );
+ while( $row = maybe_mysqli_fetch_array( $result2 ) ){
+ $name = $row['COLUMN_NAME'];
+ $type = $row['COLUMN_TYPE'];
+ $comment = ( isset( $row['COLUMN_COMMENT'] ) ? $row['COLUMN_COMMENT'] : '' );
+ $null = ( $row['IS_NULLABLE']=='YES' ? '1' : '0' );
+
+ $def = $row['COLUMN_DEFAULT'];
+ if( preg_match( '/binary/i' , $row['COLUMN_TYPE'] ) )
+ $def = bin2hex( $def );
+ if( $def=='NULL' )
+ $def = '';
+
+ $ai = ( preg_match( '/auto_increment/i' , $row['EXTRA'] ) ? '1' : '0' );
$xml .= '<row name="'.$name.'" null="'.$null.'" autoincrement="'.$ai.'">';
- $xml .= '<datatype>'.strtoupper($type).'</datatype>';
+ $xml .= '<datatype>'.strtoupper( $type ).'</datatype>';
$xml .= '<default>'.$def.'</default>';
- if ($comment) { $xml .= '<comment>'.htmlspecialchars($comment).'</comment>'; }
+ if( $comment )
+ $xml .= '<comment>'.htmlspecialchars( $comment ).'</comment>';
/* fk constraints */
- $q = "SELECT
- REFERENCED_TABLE_NAME AS 'table', REFERENCED_COLUMN_NAME AS 'column'
- FROM KEY_COLUMN_USAGE k
- LEFT JOIN TABLE_CONSTRAINTS c
- ON k.CONSTRAINT_NAME = c.CONSTRAINT_NAME
- WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'
- AND c.TABLE_SCHEMA = '".$db."' AND c.TABLE_NAME = '".$table."'
- AND k.COLUMN_NAME = '".$name."'";
- $result3 = mysql_query($q);
-
- while ($row = mysql_fetch_array($result3)) {
- $xml .= '<relation table="'.$row["table"].'" row="'.$row["column"].'" />';
+ $query = 'SELECT
+ REFERENCED_TABLE_NAME AS "table", REFERENCED_COLUMN_NAME AS "column"
+ FROM KEY_COLUMN_USAGE k
+ LEFT JOIN TABLE_CONSTRAINTS c
+ ON k.CONSTRAINT_NAME = c.CONSTRAINT_NAME
+ WHERE CONSTRAINT_TYPE = "FOREIGN KEY"
+ AND c.TABLE_SCHEMA = "'.$db.'" AND c.TABLE_NAME = "'.$table.'"
+ AND k.COLUMN_NAME = "'.$name.'"';
+ $result3 = maybe_mysqli_query( $query );
+
+ while( $row = maybe_mysqli_fetch_array( $result3 ) ){
+ $xml .= '<relation table="'.$row['table'].'" row="'.$row['column'].'" />';
}
$xml .= '</row>';
}
/* keys */
- $q = "SELECT * FROM STATISTICS WHERE TABLE_NAME = '".$table."' AND TABLE_SCHEMA = '".$db."' ORDER BY SEQ_IN_INDEX ASC";
- $result2 = mysql_query($q);
+ $query = 'SELECT * FROM STATISTICS WHERE TABLE_NAME = "'.$table.'" AND TABLE_SCHEMA = "'.$db.'" ORDER BY SEQ_IN_INDEX ASC';
+ $result2 = maybe_mysqli_query( $query );
$idx = array();
- while ($row = mysql_fetch_array($result2)) {
- $name = $row["INDEX_NAME"];
- if (array_key_exists($name, $idx)) {
+ while( $row = maybe_mysqli_fetch_array( $result2 ) ){
+ $name = $row['INDEX_NAME'];
+ if( array_key_exists( $name , $idx ) ){
$obj = $idx[$name];
- } else {
- $type = $row["INDEX_TYPE"];
- $t = "INDEX";
- if ($type == "FULLTEXT") { $t = $type; }
- if ($row["NON_UNIQUE"] == "0") { $t = "UNIQUE"; }
- if ($name == "PRIMARY") { $t = "PRIMARY"; }
+ }else{
+ $type = $row['INDEX_TYPE'];
+ $t = 'INDEX';
+ if( $type=='FULLTEXT' )
+ $t = $type;
+ if( $row['NON_UNIQUE']=='0' )
+ $t = 'UNIQUE';
+ if( $name=='PRIMARY' )
+ $t = 'PRIMARY';
$obj = array(
- "columns" => array(),
- "type" => $t
+ 'columns' => array(),
+ 'type' => $t
);
}
- $obj["columns"][] = $row["COLUMN_NAME"];
+ $obj['columns'][] = $row['COLUMN_NAME'];
$idx[$name] = $obj;
}
- foreach ($idx as $name=>$obj) {
- $xml .= '<key name="'.$name.'" type="'.$obj["type"].'">';
- for ($i=0;$i<count($obj["columns"]);$i++) {
- $col = $obj["columns"][$i];
- $xml .= '<part>'.$col.'</part>';
+ foreach( $idx as $name => $obj ){
+ $xml .= '<key name="'.$name.'" type="'.$obj['type'].'">';
+ foreach( $obj['columns'] as $col ){
+ $xml .= '<part>'.$v.'</part>';
}
$xml .= '</key>';
}
- $xml .= "</table>";
+ $xml .= '</table>';
}
$arr[] = $xml;
$arr[] = '</sql>';
- return implode("\n",$arr);
+ return implode( "\n" , $arr );
}
- $a = (isset($_GET["action"]) ? $_GET["action"] : false);
- switch ($a) {
- case "list":
+ $a = ( isset( $_GET['action'] ) ? $_GET['action'] : false );
+ switch( $a ){
+
+ case 'list' :
setup_saveloadlist();
- if (!connect()) {
- header("HTTP/1.0 503 Service Unavailable");
+ if( !connect() ){
+ header( 'HTTP/1.0 503 Service Unavailable' );
break;
}
- $result = mysql_query("SELECT keyword FROM ".TABLE." ORDER BY dt DESC");
- while ($row = mysql_fetch_assoc($result)) {
- echo $row["keyword"]."\n";
+ $result = maybe_mysqli_query( $query );
+ while( $row = maybe_mysqli_fetch_array( $result ) ){
+ echo $row['keyword']."\n";
}
break;
- case "save":
+
+ case 'save' :
setup_saveloadlist();
- if (!connect()) {
- header("HTTP/1.0 503 Service Unavailable");
+ if( !connect() ){
+ header( 'HTTP/1.0 503 Service Unavailable' );
break;
}
- $keyword = (isset($_GET["keyword"]) ? $_GET["keyword"] : "");
- $keyword = mysql_real_escape_string($keyword);
- $data = file_get_contents("php://input");
- if (get_magic_quotes_gpc() || get_magic_quotes_runtime()) {
- $data = stripslashes($data);
- }
- $data = mysql_real_escape_string($data);
- $r = mysql_query("SELECT * FROM ".TABLE." WHERE keyword = '".$keyword."'");
- if (mysql_num_rows($r) > 0) {
- $res = mysql_query("UPDATE ".TABLE." SET data = '".$data."' WHERE keyword = '".$keyword."'");
- } else {
- $res = mysql_query("INSERT INTO ".TABLE." (keyword, data) VALUES ('".$keyword."', '".$data."')");
+ $keyword = ( isset( $_GET['keyword'] ) ? $_GET['keyword'] : '' );
+ $keyword = maybe_mysqli_real_escape_string( $keyword );
+ $data = file_get_contents( 'php://input' );
+ if( get_magic_quotes_gpc() || get_magic_quotes_runtime() )
+ $data = stripslashes( $data );
+ $data = maybe_mysqli_real_escape_string( $data );
+ $query = 'SELECT * FROM '.TABLE.' WHERE keyword = "'.$keyword.'"';
+ $r = maybe_mysqli_query( $query );
+ if( maybe_mysqli_num_rows( $r ) ){
+ $query = 'UPDATE '.TABLE.' SET data = "'.$data.'" WHERE keyword = "'.$keyword.'"';
+ }else{
+ $query = 'INSERT INTO '.TABLE.' (keyword, data) VALUES ("'.$keyword.'", "'.$data.'")';
}
- if (!$res) {
- header("HTTP/1.0 500 Internal Server Error");
+ $res = maybe_mysqli_query( $query );
+ if( !$res ){
+ header( 'HTTP/1.0 500 Internal Server Error' );
} else {
- header("HTTP/1.0 201 Created");
+ header( 'HTTP/1.0 201 Created' );
}
break;
- case "load":
+
+ case 'load' :
setup_saveloadlist();
- if (!connect()) {
- header("HTTP/1.0 503 Service Unavailable");
+ if( !connect() ){
+ header( 'HTTP/1.0 503 Service Unavailable' );
break;
}
- $keyword = (isset($_GET["keyword"]) ? $_GET["keyword"] : "");
- $keyword = mysql_real_escape_string($keyword);
- $result = mysql_query("SELECT `data` FROM ".TABLE." WHERE keyword = '".$keyword."'");
- $row = mysql_fetch_assoc($result);
- if (!$row) {
- header("HTTP/1.0 404 Not Found");
- } else {
- header("Content-type: text/xml");
- echo $row["data"];
+ $keyword = ( isset( $_GET['keyword'] ) ? $_GET['keyword'] : '' );
+ $keyword = maybe_mysqli_real_escape_string( $keyword );
+ $query = 'SELECT `data` FROM '.TABLE.' WHERE keyword = "'.$keyword.'"';
+ $result = maybe_mysqli_query( $query );
+ $row = maybe_mysqli_fetch_assoc($result);
+ if( !$row ){
+ header( 'HTTP/1.0 404 Not Found' );
+ }else{
+ header( 'Content-type: text/xml' );
+ echo $row['data'];
}
break;
- case "import":
+
+ case 'import' :
setup_import();
- if (!connect()) {
- header("HTTP/1.0 503 Service Unavailable");
+ if( !connect() ){
+ header( 'HTTP/1.0 503 Service Unavailable' );
break;
}
-
- header("Content-type: text/xml");
+ header( 'Content-type: text/xml' );
echo import();
break;
- default: header("HTTP/1.0 501 Not Implemented");
+
+ default :
+ header( 'HTTP/1.0 501 Not Implemented' );
+
}
View
BIN  images/back.gif
Deleted file not rendered
View
BIN  images/back.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  styles/style.css
@@ -3,7 +3,7 @@ body {
font-size: small;
padding: 0px;
margin: 0px;
- background: url(../images/back.gif) fixed;
+ background: #FFF;
visibility: hidden;
-moz-user-select: -moz-none;
-khtml-user-select: none;
@@ -14,6 +14,7 @@ body {
#area {
position: relative;
+ background: transparent url(../images/back.png);
width: 2000px;
height: 2000px;
}
Something went wrong with that request. Please try again.