forked from deliciousbrains/sqlbuddy
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed code that could generate a notice
- Loading branch information
calvinlough
committed
Aug 27, 2008
0 parents
commit 423bb8a
Showing
89 changed files
with
17,187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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 | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
SQL Buddy - Web based MySQL administration | ||
http://www.sqlbuddy.com/ | ||
|
||
2008 Calvin Lough <http://calv.in> | ||
|
||
INTRODUCTION | ||
|
||
SQL Buddy is open source! Use of the application is governed by | ||
a MIT license - see LICENSE file for details. | ||
|
||
CHANGELOG | ||
|
||
A list of changes made in this version is available online | ||
at http://www.sqlbuddy.com/releasenotes/ | ||
|
||
INSTALLATION | ||
|
||
To start using SQL Buddy take the folder of unzipped files and | ||
ftp them to your server. I would recommend placing them in a | ||
folder such as http://www.yourserver.com/sqlbuddy/. But in | ||
reality, it shouldn't matter where you put them or what you call | ||
the folder. | ||
|
||
If you are interested, there is a few variables in config.php that you | ||
can change if you want to customize your installation. It is totally | ||
optional, and your setup will work just fine if you leave the values at | ||
their defaults. | ||
|
||
UPGRADING | ||
|
||
To upgrade SQL Buddy, its probably best to delete the old version then | ||
unzip the new version in its place. | ||
|
||
TRANSLATIONS | ||
|
||
SQL Buddy now has an online translation page. 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. | ||
|
||
KEYBOARD SHORTCUTS | ||
|
||
There is a bunch of keyboard shortcuts available to speed up things like | ||
navigating through results, editing rows, etc. A list of shortcuts is | ||
available on the home tab after you login. If you find the shortcuts | ||
annoying and would like to disable them, there is a line in main.js that you | ||
can disable. Its about 50 lines down, and I have left a comment indicating | ||
which line you need to comment out. | ||
|
||
HELP | ||
|
||
If you need help, first check http://www.sqlbuddy.com/help/ | ||
As I answer questions, I will add the answers to that page | ||
for everyone to read. | ||
|
||
If you are still having trouble, you can contact me by using | ||
the form at http://www.sqlbuddy.com/contact/ | ||
|
||
Thanks for your support, | ||
|
||
Calvin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/* | ||
SQL Buddy - Web based MySQL administration | ||
http://www.sqlbuddy.com/ | ||
ajaxcreatetable.php | ||
- called from dboverview.php to create a new table | ||
MIT license | ||
2008 Calvin Lough <http://calv.in> | ||
*/ | ||
|
||
include "functions.php"; | ||
|
||
loginCheck(); | ||
|
||
if (isset($db)) | ||
mysql_select_db($db); | ||
|
||
if (isset($_POST['query'])) | ||
{ | ||
|
||
$queryList = splitQueryText($_POST['query']); | ||
|
||
foreach ($queryList as $query) | ||
{ | ||
$sql = mysql_query($query) or ($mysqlError = mysql_error()); | ||
} | ||
|
||
if (isset($mysqlError)) | ||
{ | ||
echo $mysqlError; | ||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/* | ||
SQL Buddy - Web based MySQL administration | ||
http://www.sqlbuddy.com/ | ||
ajaxfulltext.php | ||
- fetches full text for browse tab | ||
MIT license | ||
2008 Calvin Lough <http://calv.in> | ||
*/ | ||
|
||
include "functions.php"; | ||
|
||
loginCheck(); | ||
|
||
if (isset($db)) | ||
mysql_select_db($db); | ||
|
||
if (isset($_POST['query'])) | ||
{ | ||
$queryList = splitQueryText($_POST['query']); | ||
foreach ($queryList as $query) | ||
{ | ||
$sql = mysql_query($query); | ||
} | ||
} | ||
|
||
if (@mysql_num_rows($sql)) | ||
{ | ||
$row = @mysql_fetch_assoc($sql); | ||
foreach ($row as $key => $value) | ||
{ | ||
echo "<div class=\"fulltexttitle\">" . $key . "</div>"; | ||
echo "<div class=\"fulltextbody\">" . nl2br(htmlentities($value, ENT_QUOTES, 'UTF-8')) . "</div>"; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
<?php | ||
/* | ||
SQL Buddy - Web based MySQL administration | ||
http://www.sqlbuddy.com/ | ||
ajaximportfile.php | ||
- import from file - called from import.php | ||
MIT license | ||
2008 Calvin Lough <http://calv.in> | ||
*/ | ||
|
||
include "functions.php"; | ||
|
||
loginCheck(); | ||
|
||
if (isset($db)) | ||
mysql_select_db($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 = mysql_query("DESCRIBE `$table`"); | ||
if (@mysql_num_rows($structureSQL)) | ||
{ | ||
while ($structureRow = mysql_fetch_assoc($structureSQL)) | ||
{ | ||
$columnCount++; | ||
} | ||
} | ||
} | ||
|
||
$insertCount = 0; | ||
$skipCount = 0; | ||
|
||
if (isset($file) && is_uploaded_file($file)) | ||
{ | ||
|
||
if (isset($format) && $format == "SQL") | ||
{ | ||
$lines = file($file); | ||
|
||
// the file() function handles mac line endings incorrectly | ||
// this might have been fixed in a recent version of php | ||
// if so, this code will just be ignored | ||
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); | ||
|
||
// same as before | ||
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") | ||
{ | ||
mysql_query($statement) or ($mysqlErrors[] = mysql_error()); | ||
|
||
$affected = (int)(@mysql_affected_rows()); | ||
$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; $i<sizeof($rawValues); $i++) | ||
{ | ||
$rawValues[$i] = str_replace('""', '"', $rawValues[$i]); | ||
$rawValues[$i] = mysql_real_escape_string($rawValues[$i]); | ||
} | ||
|
||
$values = implode("','", $rawValues); | ||
|
||
// make sure that the counts match up | ||
if (sizeof($rawValues) == $columnCount) | ||
{ | ||
mysql_query("INSERT INTO `$table` VALUES ('$values')") or ($mysqlErrors[] = mysql_error()); | ||
|
||
$affected = (int)(@mysql_affected_rows()); | ||
|
||
$insertCount += $affected; | ||
} | ||
else | ||
{ | ||
$skipCount++; | ||
} | ||
} | ||
$first = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
$message = ""; | ||
|
||
if (!isset($statements)) | ||
{ | ||
$message .= __("Either the file could not be read or it was empty") . "<br />"; | ||
} | ||
else if ($format == "SQL") | ||
{ | ||
$message .= sprintf(__p("%d statement was executed from the file", "%d statements were executed from the file", $insertCount), $insertCount) . ".<br />"; | ||
} | ||
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) . ".<br />"; | ||
} | ||
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) . ".<br />"; | ||
} | ||
} | ||
|
||
if (isset($mysqlErrors)) | ||
{ | ||
$message .= __("MySQL reported the following errors") . ":<br />"; | ||
foreach ($mysqlErrors as $merr) | ||
{ | ||
$message .= " - " . $merr . "<br />"; | ||
} | ||
} | ||
|
||
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | ||
"http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" version="-//W3C//DTD XHTML 1.1//EN" xml:lang="en"> | ||
<head> | ||
</head> | ||
<body> | ||
<script type="text/javascript"> | ||
|
||
parent.updateAfterImport("<?php echo trim(addslashes(nl2br($message))); ?>"); | ||
|
||
parent.refreshRowCount(); | ||
|
||
</script> | ||
</body> | ||
</html> | ||
|
||
<?php | ||
|
||
} | ||
|
||
?> |
Oops, something went wrong.