From: <sly...@us...> - 2008-08-11 06:05:44
|
Revision: 47 http://phpsqliteadmin.svn.sourceforge.net/phpsqliteadmin/?rev=47&view=rev Author: slythfox Date: 2008-08-11 06:05:54 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Fixed phpsla db alias bugs. Modified Paths: -------------- trunk/phpsqliteadmin2/changelog.txt trunk/phpsqliteadmin2/editdb.php trunk/phpsqliteadmin2/todo.txt Modified: trunk/phpsqliteadmin2/changelog.txt =================================================================== --- trunk/phpsqliteadmin2/changelog.txt 2008-07-13 18:12:55 UTC (rev 46) +++ trunk/phpsqliteadmin2/changelog.txt 2008-08-11 06:05:54 UTC (rev 47) @@ -2,6 +2,8 @@ 0.3 (xx.xx.2008) +- An error will be returned if the alias name or path is not specified. (chale) +- An error will be returned when trying to delete the phpsla.sqlite alias. (chale) - Icons have been (temporarily?) embedded into the includes file. (chale) - Added really basic multiquery support with the query page. This allows one to copy&paste a sql file and execute it in one go. (chale) - The query page now displays "x rows affected/returned". Before there was not sort of confirmation when doing non SELECT queries. (chale) Modified: trunk/phpsqliteadmin2/editdb.php =================================================================== --- trunk/phpsqliteadmin2/editdb.php 2008-07-13 18:12:55 UTC (rev 46) +++ trunk/phpsqliteadmin2/editdb.php 2008-08-11 06:05:54 UTC (rev 47) @@ -15,6 +15,14 @@ if (isset($_POST['insert'])) { // create the new db is case it does not exist + if ($alias->alias = "") { + print "An alias name needs to be provided."; + exit(); + } + if ($alias->path = "") { + print "The path to the database needs to be provided."; + exit(); + } if (!file_exists($alias->path)) $newdb =& new SPSQLite($alias->path); $sysdbh->query("insert into databases (user,alias,path,description) values ({$alias->user},'{$alias->alias}','{$alias->path}','{$alias->description}')"); // do we really want this? @@ -45,8 +53,12 @@ if (isset($_POST['delete'])) { - $sysdbh->query("delete from databases where user = {$alias->user} and alias = '{$alias->alias}'"); - //unlink($alias->path); nooooooo don't do that... + if ($alias->alias = "phpsla.sqlite") { + print "The configuration table phpsla.sqlite cannot be removed."; + exit(); + } + $sysdbh->query("delete from databases where user = '{$alias->user}' and alias = '{$alias->alias}'"); + //unlink($alias->path); nooooooo don't do that... No, that wouldn't be good. $_SESSION['phpSQLiteAdmin_currentdb'] = ''; header("Location: dbconfig.php"); exit; @@ -85,7 +97,7 @@ echo<<<EOT <br /><br /><br /><br /><br /> <form name="delete" action="editdb.php" method="post" onsubmit=""> -<input type="hidden" name="use"r value="{$current_user}" /> +<input type="hidden" name="user" value="{$current_user}" /> <input type="hidden" name="alias" value="{$_GET[alias]}" /> <input type="submit" name="delete" value="Remove this alias" /> </form> @@ -96,4 +108,4 @@ print "</body>\n"; print "</html>\n"; -?> \ No newline at end of file +?> Modified: trunk/phpsqliteadmin2/todo.txt =================================================================== --- trunk/phpsqliteadmin2/todo.txt 2008-07-13 18:12:55 UTC (rev 46) +++ trunk/phpsqliteadmin2/todo.txt 2008-08-11 06:05:54 UTC (rev 47) @@ -1,10 +1,8 @@ -Revised Todo (July, 10, 2008): - - - Don't allow the removal of the phpsla.sqlite alias. +Revised Todo (July 25, 2008): - Error checking for adding database aliases. How should general error handling work? - - Add row adding/editing/deleting. (I have a basic implimentation. -chale) + - Add row adding/editing/deleting. (We have a basic implimentation currently.) - When displaying the phpsqliteadmin version, it should display the number within the configuration table of the phpsla.sqlite database. @@ -17,12 +15,9 @@ - Feel free to add more. I was unsure of a few of entries in the old todo's. - Privilege checks for databases? - + Old Todo: -- you can add an alias database w/out the alias filled, which is bad... -- you can remove phpsla.sqlite alias, which is bad as well - - "browse" should have navigation buttons - display of indexes fails sometimes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sly...@us...> - 2008-08-11 06:44:23
|
Revision: 48 http://phpsqliteadmin.svn.sourceforge.net/phpsqliteadmin/?rev=48&view=rev Author: slythfox Date: 2008-08-11 06:44:32 +0000 (Mon, 11 Aug 2008) Log Message: ----------- Bug fix. And images no longer embedded. Modified Paths: -------------- trunk/phpsqliteadmin2/changelog.txt trunk/phpsqliteadmin2/editdb.php trunk/phpsqliteadmin2/include.php trunk/phpsqliteadmin2/leftframe.php trunk/phpsqliteadmin2/table_browse.php Added Paths: ----------- trunk/phpsqliteadmin2/images/ trunk/phpsqliteadmin2/images/database.png trunk/phpsqliteadmin2/images/delete.png trunk/phpsqliteadmin2/images/edit.png trunk/phpsqliteadmin2/images/export.png trunk/phpsqliteadmin2/images/query.png trunk/phpsqliteadmin2/images/row_insert.png trunk/phpsqliteadmin2/images/table_browse.png trunk/phpsqliteadmin2/images/table_drop.png trunk/phpsqliteadmin2/images/table_empty.png trunk/phpsqliteadmin2/images/table_structure.png Modified: trunk/phpsqliteadmin2/changelog.txt =================================================================== --- trunk/phpsqliteadmin2/changelog.txt 2008-08-11 06:05:54 UTC (rev 47) +++ trunk/phpsqliteadmin2/changelog.txt 2008-08-11 06:44:32 UTC (rev 48) @@ -2,9 +2,9 @@ 0.3 (xx.xx.2008) +- Icons have been added (no longer embedded). (chale) - An error will be returned if the alias name or path is not specified. (chale) - An error will be returned when trying to delete the phpsla.sqlite alias. (chale) -- Icons have been (temporarily?) embedded into the includes file. (chale) - Added really basic multiquery support with the query page. This allows one to copy&paste a sql file and execute it in one go. (chale) - The query page now displays "x rows affected/returned". Before there was not sort of confirmation when doing non SELECT queries. (chale) - Fixed query page's inconsistency in that it was not using htmlspecialchars. (chale) Modified: trunk/phpsqliteadmin2/editdb.php =================================================================== --- trunk/phpsqliteadmin2/editdb.php 2008-08-11 06:05:54 UTC (rev 47) +++ trunk/phpsqliteadmin2/editdb.php 2008-08-11 06:44:32 UTC (rev 48) @@ -15,11 +15,11 @@ if (isset($_POST['insert'])) { // create the new db is case it does not exist - if ($alias->alias = "") { + if ($alias->alias == "") { print "An alias name needs to be provided."; exit(); } - if ($alias->path = "") { + if ($alias->path == "") { print "The path to the database needs to be provided."; exit(); } @@ -53,7 +53,7 @@ if (isset($_POST['delete'])) { - if ($alias->alias = "phpsla.sqlite") { + if ($alias->alias == "phpsla.sqlite") { print "The configuration table phpsla.sqlite cannot be removed."; exit(); } Property changes on: trunk/phpsqliteadmin2/images/database.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/delete.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/edit.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/export.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/query.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/row_insert.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/table_browse.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/table_drop.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/table_empty.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Property changes on: trunk/phpsqliteadmin2/images/table_structure.png ___________________________________________________________________ Added: svn:executable + * Added: svn:mime-type + application/octet-stream Modified: trunk/phpsqliteadmin2/include.php =================================================================== --- trunk/phpsqliteadmin2/include.php 2008-08-11 06:05:54 UTC (rev 47) +++ trunk/phpsqliteadmin2/include.php 2008-08-11 06:44:32 UTC (rev 48) @@ -12,57 +12,6 @@ $_SESSION['phpSQLiteAdmin_currentdb'] = $_POST['sessionvalue']; } -// Embedded Images -/* -Embed images using this function: -function encode_img($img) -{ - $fd = fopen ($img, 'rb'); - $size=filesize ($img); - $cont = fread ($fd, $size); - fclose ($fd); - $encimg = base64_encode($cont); - return $encimg; -} -*/ -if (isset($_GET['imgid'])) { - switch ($_GET['imgid']) { - case "database.png": - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAAFVJREFUKFNj/P//PwN+AFQBBCcO9iyb64+MgCIQKQa49LVz2f//J0MQkA1UDVEEUgHkIEsjKyJaxcGdtWjGQGwBiqOYgeZSiCKoCmqYAQkMfL7FH2IAUp7xCV2zSGMAAAAASUVORK5CYII="; - break; - case "edit.png": - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAAGxJREFUKFN1kMENwCAIRdnVY5dwFBbosWv0wKHr0K9YikSJiSbvRT6QbqoSGRlX0homMmlhVFQ3TMoGqGp57gMMR0Qmw/F1FryBJ2OJ/xw7PIyOFb3j5z5dy2EGM3vvOPww2oRftLSb9cai9ALjByf/vas8pQAAAABJRU5ErkJggg=="; - break; - case "delete.png": - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAAFhJREFUKFOVUEEOwDAIcu/0x/5gr7E12hVM02SeFAiij7vLvabiFXHV2VCpBm4mgeaAog8pRRMBHRm28yLKzywpUKDTon954O5DDobourylRavs9I/+LJoHDOj+ebMh9FoAAAAASUVORK5CYII="; - break; - case "export.png": - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAAElJREFUKFNj+I8KGhoa0EQYkPlAaQhAFkSogEujKUIxA818CJcBTSsmF6TiAG4AlCXODKzWQwShZgBZEHuAjKVIAEUFLmOIcgcANi4S5K6eGuUAAAAASUVORK5CYII="; - break; - case "query.png": - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAAFBJREFUKFNj/P//PwN+AFRx4MCBBmwAKA7SD8RAWSCJCSDiIBVwM9YjAaA0wgyIbjST4FyQGUSpwGUA1B14rED4BdmNQDbc76T7Fi3YIL4FANr9DcnCLQhKAAAAAElFTkSuQmCC"; - break; - case "row_insert.png"; - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAAEVJREFUKFNj/P//PwMGaGxsdHBwgAoDVWCChoaGAzDAQJQKoA64OiAbDYDMgAhBFAEZz1ABQgVEET4VBMwg4A5q+Ba/GQA8fBNm+WP9jwAAAABJRU5ErkJggg=="; - break; - case "table_browse.png"; - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAADBJREFUKFNjbGhoYMAPgCoO4AYg/UCMH4BU/McNoGYAFSyFATQ2QgUuUwaZGfjDAwABxvgJEsmisgAAAABJRU5ErkJggg=="; - break; - case "table_drop.png"; - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAAE5JREFUKFNjbGhoYMAPgCoO4AYg/UCMH4BU/McNoGaAFDAw/EdWCmQDRf4DxcC2gFRAhCDq4AwUFRCLINJIhpFkBqY7wCYhmYHDO0SFBwAgBuY3U4A6ewAAAABJRU5ErkJggg=="; - break; - case "table_empty.png"; - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAAE5JREFUKFNjbGhoYMAPgCr+4wYg/XAV169fB7IhAMiG6EJRgaYUoghFBdwquEk4zYBIoNuCrA/Z3QhbIM5EdiAWlxL2C9ZAgdoCdwRWBgCNfACU8GKOGgAAAABJRU5ErkJggg=="; - break; - case "table_structure.png"; - $imgcode = "iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAIAAAAmzuBxAAAABGdBTUEAALGPC/xhBQAAACtJREFUKFNjbGhoYMAPgCr+4wYg/RAVB8AAyFiKBIBchApcpgxDM4BewgMAWDAIViqqPeEAAAAASUVORK5CYII="; - break; - } - - header('Content-type: image/png'); - echo base64_decode($imgcode); - exit(); -} function check_db() { global $current_db; @@ -110,27 +59,27 @@ <div id="currentdb">Database: {$_SESSION['phpSQLiteAdmin_currentdb']}</div> <p class="sqliteversion">SQLite version: $sqliteversion</p> <br /> -<a href="mainframe.php" target="mainframe"><img src="include.php?imgid=database.png" alt="" /> Database Info</a> | -<a href="table_structure.php?object=$current_table" target="mainframe"><img src="include.php?imgid=table_structure.png" alt="" /> Structure</a> | -<a href="table_browse.php?object=$current_table" target="mainframe"><img src="include.php?imgid=table_browse.png" alt="" /> Browse</a> | -<a href="query.php?object=$current_table" target="mainframe"><img src="include.php?imgid=query.png" alt="" /> Query</a> | -<a href="row_edit.php?object=$current_table" target="mainframe"><img src="include.php?imgid=row_insert.png" alt=\"\" /> Insert</a> | -<a href="export.php?object=$current_table" target="mainframe"><img src="include.php?imgid=export.png" alt=\"\" /> Export</a> | -<a href="dbaction.php?action=empty_table&object=$current_table" target="_top" onclick="return confirm_empty_table();"><img src="include.php?imgid=table_empty.png" alt=\"\" /> Empty</a> | -<a href="dbaction.php?action=drop_table&object=$current_table" target="_top" onclick="return confirm_drop_table();"><img src="include.php?imgid=table_drop.png" alt=\"\" /> Drop</a> +<a href="mainframe.php" target="mainframe"><img src="images/database.png" alt="" /> Database Info</a> | +<a href="table_structure.php?object=$current_table" target="mainframe"><img src="images/table_structure.png" alt="" /> Structure</a> | +<a href="table_browse.php?object=$current_table" target="mainframe"><img src="images/table_browse.png" alt="" /> Browse</a> | +<a href="query.php?object=$current_table" target="mainframe"><img src="images/query.png" alt="" /> Query</a> | +<a href="row_edit.php?object=$current_table" target="mainframe"><img src="images/row_insert.png" alt=\"\" /> Insert</a> | +<a href="export.php?object=$current_table" target="mainframe"><img src="images/export.png" alt=\"\" /> Export</a> | +<a href="dbaction.php?action=empty_table&object=$current_table" target="_top" onclick="return confirm_empty_table();"><img src="images/table_empty.png" alt=\"\" /> Empty</a> | +<a href="dbaction.php?action=drop_table&object=$current_table" target="_top" onclick="return confirm_drop_table();"><img src="images/table_drop.png" alt=\"\" /> Drop</a> EOT; } function print_table_action_links($current_table) { echo<<<EOT -<a href="table_structure.php?object=$current_table" target="mainframe"><img src="include.php?imgid=table_structure.png" alt="" /> Structure</a> | -<a href="table_browse.php?object=$current_table" target="mainframe"><img src="include.php?imgid=table_browse.png" alt="" /> Browse</a> | -<a href="query.php?object=$current_table" target="mainframe"><img src="include.php?imgid=query.png" alt="" /> Query</a> | -<a href="row_edit.php?object=$current_table" target="mainframe"><img src="include.php?imgid=row_insert.png" alt=\"\" /> Insert</a> | -<a href="export.php?object=$current_table" target="mainframe"><img src="include.php?imgid=export.png" alt=\"\" /> Export</a> | -<a href="dbaction.php?action=empty_table&object=$current_table" target="_top" onclick="return confirm_empty_table();"><img src="include.php?imgid=table_empty.png" alt="" /> Empty</a> | -<a href="dbaction.php?action=drop_table&object=$current_table" target="_top" onclick="return confirm_drop_table();"><img src="include.php?imgid=table_drop.png" alt="" /> Drop</a> +<a href="table_structure.php?object=$current_table" target="mainframe"><img src="images/table_structure.png" alt="" /> Structure</a> | +<a href="table_browse.php?object=$current_table" target="mainframe"><img src="images/table_browse.png" alt="" /> Browse</a> | +<a href="query.php?object=$current_table" target="mainframe"><img src="images/query.png" alt="" /> Query</a> | +<a href="row_edit.php?object=$current_table" target="mainframe"><img src="images/row_insert.png" alt=\"\" /> Insert</a> | +<a href="export.php?object=$current_table" target="mainframe"><img src="images/export.png" alt=\"\" /> Export</a> | +<a href="dbaction.php?action=empty_table&object=$current_table" target="_top" onclick="return confirm_empty_table();"><img src="images/table_empty.png" alt="" /> Empty</a> | +<a href="dbaction.php?action=drop_table&object=$current_table" target="_top" onclick="return confirm_drop_table();"><img src="images/table_drop.png" alt="" /> Drop</a> EOT; } Modified: trunk/phpsqliteadmin2/leftframe.php =================================================================== --- trunk/phpsqliteadmin2/leftframe.php 2008-08-11 06:05:54 UTC (rev 47) +++ trunk/phpsqliteadmin2/leftframe.php 2008-08-11 06:44:32 UTC (rev 48) @@ -38,7 +38,7 @@ print "<li class=\"list_title\" title=\"Tables in database $current_db\">Tables</li>\n"; $userdbh->query("select name,upper(name) from SQLITE_MASTER where type = 'table' order by 2"); while($row = $userdbh->fetchArray()) { - print "<li><a href=\"table_browse.php?object=".$row[0]."\"><img src=\"include.php?imgid=table_browse.png\" alt=\"Browse table\" title=\"Browse table\" /></a> <a href=\"table_structure.php?object=".$row[0]."\">$row[0]</a></li>\n"; + print "<li><a href=\"table_browse.php?object=".$row[0]."\"><img src=\"images/table_browse.png\" alt=\"Browse\" title=\"Browse table\" /></a> <a href=\"table_structure.php?object=".$row[0]."\">$row[0]</a></li>\n"; } print "</ul>\n</div>\n"; } Modified: trunk/phpsqliteadmin2/table_browse.php =================================================================== --- trunk/phpsqliteadmin2/table_browse.php 2008-08-11 06:05:54 UTC (rev 47) +++ trunk/phpsqliteadmin2/table_browse.php 2008-08-11 06:44:32 UTC (rev 48) @@ -48,8 +48,8 @@ //$rows = $userdbh->returnRows('num'); //$table->print_header(); print "<tr>\n"; - print "<td><a href=\"row_edit.php?object=" .$_GET['object']. "&primary_key=" .$primary_key. "&row=" .$row[$primary_key_order]. "\"><img src=\"include.php?imgid=edit.png\" alt=\"Edit\" title=\"Edit\" /></a></td> -<td><a href=\"row_edit.php?object=" .$_GET['object']. "&primary_key=" .$primary_key. "&row=" .$row[$primary_key_order]. "&type=delete\" onclick=\"return confirm_delete_row();\"><img src=\"include.php?imgid=delete.png\" alt=\"Delete\" title=\"Delete\" /></a></td>\n"; + print "<td><a href=\"row_edit.php?object=" .$_GET['object']. "&primary_key=" .$primary_key. "&row=" .$row[$primary_key_order]. "\"><img src=\"images/edit.png\" alt=\"Edit\" title=\"Edit\" /></a></td> +<td><a href=\"row_edit.php?object=" .$_GET['object']. "&primary_key=" .$primary_key. "&row=" .$row[$primary_key_order]. "&type=delete\" onclick=\"return confirm_delete_row();\"><img src=\"images/delete.png\" alt=\"Delete\" title=\"Delete\" /></a></td>\n"; for ($i=0; $i<$nr_fields; $i++) { if (strlen($row[$i]) > 50) { print '<td>'.substr(htmlentities($row[$i],ENT_QUOTES,$encoding),0,50)."...</td>\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2009-11-24 11:50:32
|
Revision: 52 http://phpsqliteadmin.svn.sourceforge.net/phpsqliteadmin/?rev=52&view=rev Author: warddr Date: 2009-11-24 11:50:25 +0000 (Tue, 24 Nov 2009) Log Message: ----------- Removed a coupe of bugs from row_edit.php added a "null?" column to row_edit.php (if you check null the primary key will be auto assigned by sqlite, if you don't do so an empty string will be sent as primary key, that will result in an error). Modified Paths: -------------- trunk/phpsqliteadmin2/row_edit.php trunk/phpsqliteadmin2/todo.txt Modified: trunk/phpsqliteadmin2/row_edit.php =================================================================== --- trunk/phpsqliteadmin2/row_edit.php 2009-11-22 22:14:05 UTC (rev 51) +++ trunk/phpsqliteadmin2/row_edit.php 2009-11-24 11:50:25 UTC (rev 52) @@ -1,183 +1,193 @@ -<?php - -require_once('include.php'); - -// Query (form submitted) portion -if ($_POST['type'] == "edit") { - - if (!$_GET['primary_key']) { - print "Table needs a primary key identifier."; - exit(); - } - - //print "<h3>Edit Row</h3>"; - - foreach (array_keys($_POST) as $column) { - // Only do columns, not $_POST['type'] and so on... - if (strstr($column, "column__") !== false) { - $columns .= ", " .str_replace("column__", "", $column). " = '" .$_POST[$column]. "'"; - } - //echo $column. "<br>"; - - } - // Clean up columns: - $columns = "randomkeytoberemoved" .$columns; - $columns = str_replace("randomkeytoberemoved, ", "", $columns); - //print $columns; - - $userdbh->query("UPDATE " .$_POST['object']. " SET " .$columns. " WHERE " .$_POST['primary_key']. " = '" .$_POST['row']. "'"); - $_SESSION['phpSQLiteAdmin_currentdb'] = ''; - header("Location: table_browse.php?object=" .$_POST['object']. ""); - exit(); - -} else if ($_POST['type'] == "add") { - - //print "<h3>Add Row</h3>"; - - foreach (array_keys($_POST) as $column) { - // Only do columns, not $_POST['type'] and so on... - if (strstr($column, "column__") !== false) { - $columns .= str_replace("column__", "", $column). ", "; - $values .= "'" .$_POST[$column]. "', "; - } - //echo $column. "<br>"; - - } - // Clean up columns/values: - $columns = $columns. "randomkeytoberemoved"; - $columns = str_replace(", randomkeytoberemoved", "", $columns); - $values = $values. "randomkeytoberemoved"; - $values = str_replace(", randomkeytoberemoved", "", $values); - //print $columns. "<br>"; - //print $values; - - $userdbh->query("INSERT INTO " .$_POST['object']. "(" .$columns. ") VALUES(" .$values. ")"); - header("Location: table_browse.php?object=" .$_POST['object']. ""); - exit(); - -} -if ($_GET['type'] == "delete") { - if (!$_GET['primary_key']) { - print "Table needs a primary key identifier."; - exit(); - } - - $userdbh->query("delete from ".$_GET['object']. " where " .$_GET['primary_key']. " = '" .$_GET['row']. "'"); - header("Location: table_browse.php?object=" .$_GET['object']. ""); - exit(); -} - -?> -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> -<html> -<head> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <title>phpSQLiteAdmin</title> - <meta http-equiv="expires" content="0"> - <script language="Javascript" src="javascript.txt" type="text/javascript"></script> - <link href="phpsla.css" rel="stylesheet" type="text/css"> -</head> -<body class="right"> -<?php - -print_top_links($_GET['object']); - -// Show main content: add or edit a row form. -if (!$_GET['row']) { - $type = "add"; -} else { - $type = "edit"; -} - -if (!$_GET['object']) { - print "Error: No table selected."; -} - -if ($type == "edit") { - print "<h3>Edit Row from Table '{$_GET['object']}'</h3>\n"; -} else { - print "<h3>Add Row to Table '{$_GET['object']}'</h3>\n"; -} - -print "<form action=\"row_edit.php\" method=\"post\">"; -print "<table border=\"1\">\n"; -print "<tr><th>Column</th><th>Type</th><th>Value</th></tr>\n"; -$userdbh->_setTableInfo($_GET['object']); -$cols = $userdbh->getColsType(); -$k = 0; -while (list($key,$value) = each($cols)) { - $col_name[$k] = $key; - $col_value[$k] = strtolower($value); - - // Clean up col_value to only display databtype. - if ($col_value[$k] == "") { $col_value[$k] = "typeless"; } - //if (strpos(strtolower(" " .$col_value[$k]. " "), "text")) { $col_value[$k] = "text"; } - $col_value[$k] = str_replace("not null", "", $col_value[$k]); - $col_value[$k] = str_replace("null", "", $col_value[$k]); - $col_value[$k] = str_replace("primary key", "", $col_value[$k]); - $col_value[$k] = str_replace("default", "", $col_value[$k]); - $col_value[$k] = preg_replace("/\'[^>]*\'/iU", "", $col_value[$k]); - $col_value[$k] = preg_replace("/\"[^>]*\"/iU", "", $col_value[$k]); - - $k++; -} - -if ($type == "edit") { - $userdbh->query("select * from ".$_GET['object']. " where " .$_GET['primary_key']. " = '" .$_GET['row']. "'"); - //$userdbh->query('select * from '.$_GET['object']); - while($row = $userdbh->fetchArray()) { - $nr_fields = count($row); - for ($i=0; $i<$nr_fields; $i++) { - print "<tr>\n"; - print "<td>" .$col_name[$i]. "</td>\n"; - print "<td>" .$col_value[$i]. "</td>\n"; - if (strpos(" " .$col_value[$i]. " ", "text")) { - print "<td><textarea name=\"column__" .$col_name[$i]. "\">" .$row[$i]. "</textarea></td>\n"; - } else { - print "<td><input type=\"text\" name=\"column__" .$col_name[$i]. "\" value=\"" .$row[$i]. "\" /></td>\n"; - } - print "</tr>\n"; - } - } -} else { - $nr_fields = count($col_name); - for ($i=0; $i<$nr_fields; $i++) { - print "<tr>\n"; - print "<td>" .$col_name[$i]. "</td>\n"; - print "<td>" .$col_value[$i]. "</td>\n"; - if (strpos(" " .$col_value[$i]. " ", "text")) { - print "<td><textarea name=\"column__" .$col_name[$i]. "\"></textarea></td>\n"; - } else { - print "<td><input type=\"text\" name=\"column__" .$col_name[$i]. "\" value=\"\" /></td>\n"; - } - print "</tr>\n"; - } -} -print "<tr>\n<th></th>\n<th></th>\n<th>"; -print "<input type=\"hidden\" name=\"row\" value=\"" .$_GET['row']. "\" />\n"; -print "<input type=\"hidden\" name=\"primary_key\" value=\"" .$_GET['primary_key']. "\" />\n"; -print "<input type=\"hidden\" name=\"object\" value=\"" .$_GET['object']. "\" />\n"; -print "<input type=\"hidden\" name=\"type\" value=\"" .$type. "\" />\n"; -print "<input type=\"submit\" name=\"\" value=\"Save\" />\n"; -print "<input type=button value=\"Cancel\" onclick=\"history.back();\">"; -print "</th>\n</table>\n"; -print "</form>"; - -/* -print "<table border=1>\n"; -print "<tr><th>Column</th><th>Type</th></tr>\n"; -$userdbh->_setTableInfo($_GET['object']); -$cols = $userdbh->getColsType(); -while (list($key,$value) = each($cols)) { - print "<tr><td>$key</td><td>$value</td></tr>\n"; -} -print "</table>\n"; - -print "<p>Rows in table: ".$userdbh->numRows($_GET['object'])."</p>\n"; -*/ - -print "</body>\n"; -print "</html>\n"; - - -?> +<?php + +require_once('include.php'); + +// Query (form submitted) portion +if ($_POST['type'] == "edit") { + + if (!isset($_POST['primary_key']) || ($_POST['primary_key'] == "")) { + print "Table needs a primary key identifier."; + exit(); + } + + //print "<h3>Edit Row</h3>"; + + foreach (array_keys($_POST) as $column) { + // Only do columns, not $_POST['type'] and so on... + if (strstr($column, "column__") !== false) { + $columns .= ", " .str_replace("column__", "", $column). " = '" .$_POST[$column]. "'"; + } + //echo $column. "<br>"; + + } + // Clean up columns: + $columns = "randomkeytoberemoved" .$columns; + $columns = str_replace("randomkeytoberemoved, ", "", $columns); + //print $columns; + + $userdbh->query("UPDATE " .$_POST['object']. " SET " .$columns. " WHERE " .$_POST['primary_key']. " = '" .$_POST['row']. "'"); + $_SESSION['phpSQLiteAdmin_currentdb'] = ''; + header("Location: table_browse.php?object=" .$_POST['object']. ""); + exit(); + +} else if ($_POST['type'] == "add") { + + //print "<h3>Add Row</h3>"; + + foreach (array_keys($_POST) as $column) { + // Only do columns, not $_POST['type'] and so on... + if (strstr($column, "column__") !== false) { + if (!isset($_POST["null_".str_replace("column__", "", $column)])){ + $columns .= str_replace("column__", "", $column). ", "; + $values .= "'" .$_POST[$column]. "', "; + } + } + //echo $column. "<br>"; + + } + // Clean up columns/values: + $columns = $columns. "randomkeytoberemoved"; + $columns = str_replace(", randomkeytoberemoved", "", $columns); + $values = $values. "randomkeytoberemoved"; + $values = str_replace(", randomkeytoberemoved", "", $values); + //print $columns. "<br>"; + //print $values; + + $userdbh->query("INSERT INTO " .$_POST['object']. "(" .$columns. ") VALUES(" .$values. ")"); + header("Location: table_browse.php?object=" .$_POST['object']. ""); + exit(); + +} +if ($_GET['type'] == "delete") { + if (!$_GET['primary_key']) { + print "Table needs a primary key identifier."; + exit(); + } + + $userdbh->query("delete from ".$_GET['object']. " where " .$_GET['primary_key']. " = '" .$_GET['row']. "'"); + header("Location: table_browse.php?object=" .$_GET['object']. ""); + exit(); +} + +?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> + <title>phpSQLiteAdmin</title> + <meta http-equiv="expires" content="0"> + <script language="Javascript" src="javascript.txt" type="text/javascript"></script> + <link href="phpsla.css" rel="stylesheet" type="text/css"> +</head> +<body class="right"> +<?php + +print_top_links($_GET['object']); + +// Show main content: add or edit a row form. +if (!isset($_GET['row'])) { + $type = "add"; +} else { + $type = "edit"; +} + +if (!$_GET['object']) { + print "Error: No table selected."; +} + +if ($type == "edit") { + if (!isset($_GET['primary_key']) || ($_GET['primary_key'] == "")) { + print "<h3>Table needs a primary key identifier.</h3>"; + exit(); + } + print "<h3>Edit Row from Table '{$_GET['object']}'</h3>\n"; +} else { + print "<h3>Add Row to Table '{$_GET['object']}'</h3>\n"; +} + +print "<form action=\"row_edit.php\" method=\"post\">"; +print "<table border=\"1\">\n"; +$userdbh->_setTableInfo($_GET['object']); +$cols = $userdbh->getColsType(); +$k = 0; +while (list($key,$value) = each($cols)) { + $col_name[$k] = $key; + $col_value[$k] = strtolower($value); + + // Clean up col_value to only display databtype. + if ($col_value[$k] == "") { $col_value[$k] = "typeless"; } + //if (strpos(strtolower(" " .$col_value[$k]. " "), "text")) { $col_value[$k] = "text"; } + $col_value[$k] = str_replace("not null", "", $col_value[$k]); + $col_value[$k] = str_replace("null", "", $col_value[$k]); + $col_value[$k] = str_replace("unique", "", $col_value[$k]); + $col_value[$k] = str_replace("primary key", "", $col_value[$k]); + $col_value[$k] = str_replace("default", "", $col_value[$k]); + $col_value[$k] = preg_replace("/\'[^>]*\'/iU", "", $col_value[$k]); + $col_value[$k] = preg_replace("/\"[^>]*\"/iU", "", $col_value[$k]); + + $k++; +} + +if ($type == "edit") { + print "<tr><th>Column</th><th>Type</th><th>Value</th></tr>\n"; + $userdbh->query("select * from ".$_GET['object']. " where " .$_GET['primary_key']. " = '" .$_GET['row']. "'"); + //$userdbh->query('select * from '.$_GET['object']); + while($row = $userdbh->fetchArray()) { + $nr_fields = count($row); + for ($i=0; $i<$nr_fields; $i++) { + print "<tr>\n"; + print "<td>" .$col_name[$i]. "</td>\n"; + print "<td>" .$col_value[$i]. "</td>\n"; + if (strpos(" " .$col_value[$i]. " ", "text")) { + print "<td><textarea name=\"column__" .$col_name[$i]. "\">" .$row[$i]. "</textarea></td>\n"; + } else { + print "<td><input type=\"text\" name=\"column__" .$col_name[$i]. "\" value=\"" .$row[$i]. "\" /></td>\n"; + } + print "</tr>\n"; + } + } +} else { + print "<tr><th>Column</th><th>Type</th><th>Value</th><th>null?</th></tr>\n"; + $nr_fields = count($col_name); + for ($i=0; $i<$nr_fields; $i++) { + print "<tr>\n"; + print "<td>" .$col_name[$i]. "</td>\n"; + print "<td>" .$col_value[$i]. "</td>\n"; + if (strpos(" " .$col_value[$i]. " ", "text")) { + print "<td><textarea name=\"column__" .$col_name[$i]. "\"></textarea></td>\n"; + } else { + print "<td><input type=\"text\" name=\"column__" .$col_name[$i]. "\" value=\"\" /></td>\n"; + } + print "<td><input type=\"checkbox\" name=\"null__" .$col_name[$i]. "\" value=\"\" onclick=\"column__".$col_name[$i].".disabled = this.checked ? true : false\" /></td>\n"; + print "</tr>\n"; + } +} +print "<tr>\n<th></th>\n<th></th>\n<th>"; +print "<input type=\"hidden\" name=\"row\" value=\"" .$_GET['row']. "\" />\n"; +print "<input type=\"hidden\" name=\"primary_key\" value=\"" .$_GET['primary_key']. "\" />\n"; +print "<input type=\"hidden\" name=\"object\" value=\"" .$_GET['object']. "\" />\n"; +print "<input type=\"hidden\" name=\"type\" value=\"" .$type. "\" />\n"; +print "<input type=\"submit\" name=\"\" value=\"Save\" />\n"; +print "<input type=button value=\"Cancel\" onclick=\"history.back();\">"; +if ($type == "add") (print "</th>\n<th>\n"); +print "</th>\n</table>\n"; +print "</form>"; + +/* +print "<table border=1>\n"; +print "<tr><th>Column</th><th>Type</th></tr>\n"; +$userdbh->_setTableInfo($_GET['object']); +$cols = $userdbh->getColsType(); +while (list($key,$value) = each($cols)) { + print "<tr><td>$key</td><td>$value</td></tr>\n"; +} +print "</table>\n"; + +print "<p>Rows in table: ".$userdbh->numRows($_GET['object'])."</p>\n"; +*/ + +print "</body>\n"; +print "</html>\n"; + + +?> Modified: trunk/phpsqliteadmin2/todo.txt =================================================================== --- trunk/phpsqliteadmin2/todo.txt 2009-11-22 22:14:05 UTC (rev 51) +++ trunk/phpsqliteadmin2/todo.txt 2009-11-24 11:50:25 UTC (rev 52) @@ -16,11 +16,7 @@ - Privilege checks for databases? -COMPLETED BY WARDDR (November 22, 2009): - - - Fix "Table needs a primary key identifier." error, and try to find a way that the id isn't needed - - Row adding: make autoincrement possible - + Old Todo: - "browse" should have navigation buttons This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |