Commit e3a52934e7b70e7bbeb900a1bf717680dd518416

Authored by Edmar Moretti
1 parent 272dcb34

remocão de arquivos desnecessarios

pacotes/phpliteadmin/README.txt
@@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
1 -INSTALLATION:  
2 -  
3 - 1. Open phpliteadmin.php in a text editor.  
4 -  
5 - 2. If you want to have a directory scanned for your databases instead of listing them manually, specify the directory as the value of the $directory variable and skip to step 4.  
6 -  
7 - 3. If you want to specify your databases manually, set the value of the $directory variable as false and modify the $databases array to hold the databases you would like to manage.  
8 -  
9 - - The path field is the file path of the database relative to where phpliteadmin.php will be located on the server. For example, if phpliteadmin.php is located at "databases/manager/phpliteadmin.php" and you want to manage "databases/yourdatabase.sqlite", the path value would be "../yourdatabase.sqlite".  
10 -  
11 - - The name field is the human-friendly way of referencing the database within the application. It can be anything you want.  
12 -  
13 - 4. Modify the $password variable to be the password used for gaining access to the phpLiteAdmin tool.  
14 -  
15 - 5. If you want to have multiple installations of phpLiteAdmin on the same server, change the $cookie_name variable to be unique for each installation (optional).  
16 -  
17 - 6. Save and upload phpliteadmin.php to your web server.  
18 -  
19 - 7. Open a web browser and navigate to the uploaded phpliteadmin.php file. You will be prompted to enter a password. Use the same password you set in step 4.  
20 -  
21 -INSTALLING A THEME:  
22 -  
23 - 1. Download the themes package from the project Downloads page.  
24 -  
25 - 2. Unzip the file and choose your desired theme.  
26 -  
27 - 3. Upload phpliteadmin.css from the theme's directory alongside phpliteadmin.php.  
28 -  
29 - 4. Your theme will automatically override the default.  
30 -  
31 -REQUIREMENTS:  
32 -  
33 - - a server with PHP installed  
34 -  
35 - - at least one PHP SQLite library extension installed and enabled: PDO, SQLite3, or SQLiteDatabase  
36 -  
37 -  
38 -GETTING HELP:  
39 -  
40 - The project's wiki provides information on how to do certain things and is located at http://code.google.com/p/phpliteadmin/w/list. In addition, the project's discussion group is located at http://groups.google.com/group/phpliteadmin.  
41 -  
42 -  
43 -REPORTING ERRORS AND BUGS:  
44 -  
45 - If you find any issues while using the tool, please report them at http://code.google.com/p/phpliteadmin/issues/list.  
46 \ No newline at end of file 0 \ No newline at end of file
pacotes/phpliteadmin/phpliteadmin.php
@@ -1,3154 +0,0 @@ @@ -1,3154 +0,0 @@
1 -<?php  
2 -  
3 -//  
4 -// Project: phpLiteAdmin (http://phpliteadmin.googlecode.com)  
5 -// Version: 1.8.6  
6 -// Summary: PHP-based admin tool to manage SQLite2 and SQLite3 databases on the web  
7 -// Last updated: 5/31/11  
8 -// Developers:  
9 -// Dane Iracleous (daneiracleous@gmail.com)  
10 -// Ian Aldrighetti (ian.aldrighetti@gmail.com)  
11 -// George Flanagin & Digital Gaslight, Inc (george@digitalgaslight.com)  
12 -//  
13 -//  
14 -// Copyright (C) 2011 phpLiteAdmin  
15 -//  
16 -// This program is free software: you can redistribute it and/or modify  
17 -// it under the terms of the GNU General Public License as published by  
18 -// the Free Software Foundation, either version 3 of the License, or  
19 -// (at your option) any later version.  
20 -//  
21 -// This program is distributed in the hope that it will be useful,  
22 -// but WITHOUT ANY WARRANTY; without even the implied warranty of  
23 -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
24 -// GNU General Public License for more details.  
25 -//  
26 -// You should have received a copy of the GNU General Public License  
27 -// along with this program. If not, see <http://www.gnu.org/licenses/>.  
28 -//  
29 -///////////////////////////////////////////////////////////////////////////  
30 -//adicionado por edmar  
31 -include_once (dirname(__FILE__)."/../../ms_configura.php");  
32 -$editor = false;  
33 -if (strtolower($_SERVER['HTTP_HOST']) !== "localhost")  
34 -{echo "Acesso permitido apenas via localhost";exit;}  
35 -//please report any bugs you encounter to http://code.google.com/p/phpliteadmin/issues/list  
36 -//password to gain access (change this to something more secure than 'admin')  
37 -//$password = "admin";  
38 -include_once("senha.php");  
39 -if($conexaoadmin == ""){  
40 - //directory relative to this file to search for SQLite databases (if false, manually list databases below)  
41 - $directory = "../../admin";  
42 - //an array of databases that will appear in the application (if $directory is anything but false, $databases will be ignored)  
43 - //if any of the databases do not exist as they are referenced by their path, they will be created automatically if possible  
44 - //the SQLite version of each database is determined automatically  
45 - $databases = array  
46 - (  
47 - array  
48 - (  
49 - "path"=> "admin.db",  
50 - "name"=> "admin.db"  
51 - )  
52 - );  
53 -}  
54 -else{  
55 - include_once($conexaoadmin);  
56 - //$arquivosqlite = $locaplic."/sfb/admin.db";  
57 - $directory = dirname($arquivosqlite);  
58 - $databases = array  
59 - (  
60 - array  
61 - (  
62 - "path"=> basename($arquivosqlite),  
63 - "name"=> "admin.db"  
64 - )  
65 - );  
66 - $conAdmin = "";  
67 - $conAdminw = "";  
68 - $dbhw = "";  
69 - $dbh = "";  
70 -}  
71 -// What should the name of the cookie be which contains the current password?  
72 -// Changing this allows multiple phpLiteAdmin installs to work under the same domain.  
73 -$cookie_name = 'pla3412';  
74 -  
75 -//end of the variables you may need to edit  
76 -  
77 -session_start(); //don't mess with this - required for the login session  
78 -date_default_timezone_set(date_default_timezone_get()); //needed to fix STRICT warnings about timezone issues  
79 -  
80 -//toggle error reporting  
81 -//ini_set("display_errors", 1);  
82 -//error_reporting(E_STRICT | E_ALL);  
83 -  
84 -$startTimeTot = microtime(true); //start the timer to record page load time  
85 -  
86 -//the salt and password encrypting is probably unnecessary protection but is done just for the sake of being very secure  
87 -//create a random salt for this session if a cookie doesn't already exist for it  
88 -if(!isset($_SESSION[$cookie_name.'_salt']) && !isset($_COOKIE[$cookie_name.'_salt']))  
89 -{  
90 - $n = rand(10e16, 10e20);  
91 - $_SESSION[$cookie_name.'_salt'] = base_convert($n, 10, 36);  
92 -}  
93 -else if(!isset($_SESSION[$cookie_name.'_salt']) && isset($_COOKIE[$cookie_name.'_salt'])) //session doesn't exist, but cookie does so grab it  
94 -{  
95 - $_SESSION[$cookie_name.'_salt'] = $_COOKIE[$cookie_name.'_salt'];  
96 -}  
97 -  
98 -//build the basename of this file for later reference  
99 -$info = pathinfo($_SERVER['PHP_SELF']);  
100 -$thisName = $info['basename'];  
101 -  
102 -//constants  
103 -define("PROJECT", "phpLiteAdmin");  
104 -define("VERSION", "1.8.6");  
105 -define("PAGE", $thisName);  
106 -define("COOKIENAME", $cookie_name);  
107 -define("SYSTEMPASSWORD", $password); // Makes things easier.  
108 -define("SYSTEMPASSWORDENCRYPTED", md5($password."_".$_SESSION[$cookie_name.'_salt'])); //extra security - salted and encrypted password used for checking  
109 -define("FORCETYPE", false); //force the extension that will be used (set to false in almost all circumstances except debugging)  
110 -  
111 -//data types array  
112 -$types = array("INTEGER", "REAL", "TEXT", "BLOB");  
113 -define("DATATYPES", serialize($types));  
114 -  
115 -//available SQLite functions array  
116 -$functions = array("abs", "date", "datetime", "hex", "julianday", "length", "lower", "ltrim", "random", "round", "rtrim", "soundex", "time", "trim", "typeof", "upper");  
117 -define("FUNCTIONS", serialize($functions));  
118 -  
119 -//if the user wants to scan a directory for databases, do so  
120 -if($directory!==false)  
121 -{  
122 - if($directory[strlen($directory)-1]=="/") //if user has a trailing slash in the directory, remove it  
123 - $directory = substr($directory, 0, strlen($directory)-1);  
124 -  
125 - if(is_dir($directory)) //make sure the directory is valid  
126 - {  
127 - $arr = scandir($directory);  
128 - $databases = array();  
129 - $j = 0;  
130 - for($i=0; $i<sizeof($arr); $i++) //iterate through all the files in the databases  
131 - {  
132 - $file = pathinfo($arr[$i]);  
133 - if(isset($file['extension']))  
134 - {  
135 - $ext = strtolower($file['extension']);  
136 - if($ext=="sqlite" || $ext=="db" || $ext=="sqlite3" || $ext=="db3") //make sure the file is a valid SQLite database by checking its extension  
137 - {  
138 - $databases[$j]['path'] = $directory."/".$arr[$i];  
139 - $databases[$j]['name'] = $arr[$i];  
140 - $j++;  
141 - }  
142 - }  
143 - }  
144 - }  
145 - else //the directory is not valid - display error and exit  
146 - {  
147 - echo "<div class='confirm' style='margin:20px;'>";  
148 - echo "The directory you specified to scan for databases does not exist or is not a directory.";  
149 - echo "</div>";  
150 - exit();  
151 - }  
152 -}  
153 -//  
154 -// Authorization class  
155 -// Maintains user's logged-in state and security of application  
156 -//  
157 -class Authorization  
158 -{  
159 - public function grant($remember)  
160 - {  
161 - if($remember) //user wants to be remembered, so set a cookie  
162 - {  
163 - $expire = time()+60*60*24*30; //set expiration to 1 month from now  
164 - setcookie(COOKIENAME, SYSTEMPASSWORD, $expire);  
165 - setcookie(COOKIENAME."_salt", $_SESSION[COOKIENAME.'_salt'], $expire);  
166 - }  
167 - else  
168 - {  
169 - //user does not want to be remembered, so destroy any potential cookies  
170 - setcookie(COOKIENAME, "", time()-86400);  
171 - setcookie(COOKIENAME."_salt", "", time()-86400);  
172 - unset($_COOKIE[COOKIENAME]);  
173 - unset($_COOKIE[COOKIENAME.'_salt']);  
174 - }  
175 -  
176 - $_SESSION[COOKIENAME.'password'] = SYSTEMPASSWORDENCRYPTED;  
177 - }  
178 - public function revoke()  
179 - {  
180 - //destroy everything - cookies and session vars  
181 - setcookie(COOKIENAME, "", time()-86400);  
182 - setcookie(COOKIENAME."_salt", "", time()-86400);  
183 - unset($_COOKIE[COOKIENAME]);  
184 - unset($_COOKIE[COOKIENAME.'_salt']);  
185 - session_unset();  
186 - session_destroy();  
187 - }  
188 - public function isAuthorized()  
189 - {  
190 - // Is this just session long? (What!?? -DI)  
191 - if((isset($_SESSION[COOKIENAME.'password']) && $_SESSION[COOKIENAME.'password'] == SYSTEMPASSWORDENCRYPTED) || (isset($_COOKIE[COOKIENAME]) && isset($_COOKIE[COOKIENAME.'_salt']) && md5($_COOKIE[COOKIENAME]."_".$_COOKIE[COOKIENAME.'_salt']) == SYSTEMPASSWORDENCRYPTED))  
192 - return true;  
193 - else  
194 - {  
195 - return false;  
196 - }  
197 - }  
198 -}  
199 -  
200 -//  
201 -// Database class  
202 -// Generic database abstraction class to manage interaction with database without worrying about SQLite vs. PHP versions  
203 -//  
204 -class Database  
205 -{  
206 - protected $db; //reference to the DB object  
207 - protected $type; //the extension for PHP that handles SQLite  
208 - protected $data;  
209 - protected $lastResult;  
210 -  
211 - public function __construct($data)  
212 - {  
213 - $this->data = $data;  
214 - try  
215 - {  
216 - if(file_exists($this->data["path"]) && !is_writable($this->data["path"])) //make sure the actual database file is writable  
217 - {  
218 - echo "<div class='confirm' style='margin:20px;'>";  
219 - echo "The database, '".$this->data["path"]."', is not writable. The application is unusable until you make it writable.";  
220 - echo "<form action='".PAGE."' method='post'/>";  
221 - echo "<input type='submit' value='Log Out' name='logout' class='btn'/>";  
222 - echo "</form>";  
223 - echo "</div><br/>";  
224 - exit();  
225 - }  
226 -  
227 - if(!file_exists($this->data["path"]) && !is_writable(dirname($this->data["path"]))) //make sure the containing directory is writable if the database does not exist  
228 - {  
229 - echo "<div class='confirm' style='margin:20px;'>";  
230 - echo "The database, '".$this->data["path"]."', does not exist and cannot be created because the containing directory, '".dirname($this->data["path"])."', is not writable. The application is unusable until you make it writable.";  
231 - echo "<form action='".PAGE."' method='post'/>";  
232 - echo "<input type='submit' value='Log Out' name='logout' class='btn'/>";  
233 - echo "</form>";  
234 - echo "</div><br/>";  
235 - exit();  
236 - }  
237 -  
238 - $ver = $this->getVersion();  
239 -  
240 - switch(true)  
241 - {  
242 - case (FORCETYPE=="PDO" || ((FORCETYPE==false || $ver!=-1) && class_exists("PDO") && ($ver==-1 || $ver==3))):  
243 - $this->db = new PDO("sqlite:".$this->data['path']);  
244 - if($this->db!=NULL)  
245 - {  
246 - $this->type = "PDO";  
247 - break;  
248 - }  
249 - case (FORCETYPE=="SQLite3" || ((FORCETYPE==false || $ver!=-1) && class_exists("SQLite3") && ($ver==-1 || $ver==3))):  
250 - $this->db = new SQLite3($this->data['path']);  
251 - if($this->db!=NULL)  
252 - {  
253 - $this->type = "SQLite3";  
254 - break;  
255 - }  
256 - case (FORCETYPE=="SQLiteDatabase" || ((FORCETYPE==false || $ver!=-1) && class_exists("SQLiteDatabase") && ($ver==-1 || $ver==2))):  
257 - $this->db = new SQLiteDatabase($this->data['path']);  
258 - if($this->db!=NULL)  
259 - {  
260 - $this->type = "SQLiteDatabase";  
261 - break;  
262 - }  
263 - default:  
264 - $this->showError();  
265 - exit();  
266 - }  
267 - }  
268 - catch(Exception $e)  
269 - {  
270 - $this->showError();  
271 - exit();  
272 - }  
273 - }  
274 -  
275 - public function showError()  
276 - {  
277 - $classPDO = class_exists("PDO");  
278 - $classSQLite3 = class_exists("SQLite3");  
279 - $classSQLiteDatabase = class_exists("SQLiteDatabase");  
280 - if($classPDO)  
281 - $strPDO = "installed";  
282 - else  
283 - $strPDO = "not installed";  
284 - if($classSQLite3)  
285 - $strSQLite3 = "installed";  
286 - else  
287 - $strSQLite3 = "not installed";  
288 - if($classSQLiteDatabase)  
289 - $strSQLiteDatabase = "installed";  
290 - else  
291 - $strSQLiteDatabase = "not installed";  
292 - echo "<div class='confirm' style='margin:20px;'>";  
293 - echo "There was a problem setting up your database, ".$this->getPath().". An attempt will be made to find out what's going on so you can fix the problem more easily.<br/><br/>";  
294 - echo "<i>Checking supported SQLite PHP extensions...<br/><br/>";  
295 - echo "<b>PDO</b>: ".$strPDO."<br/>";  
296 - echo "<b>SQLite3</b>: ".$strSQLite3."<br/>";  
297 - echo "<b>SQLiteDatabase</b>: ".$strSQLiteDatabase."<br/><br/>...done.</i><br/><br/>";  
298 - if(!$classPDO && !$classSQLite3 && !$classSQLiteDatabase)  
299 - echo "It appears that none of the supported SQLite library extensions are available in your installation of PHP. You may not use ".PROJECT." until you install at least one of them.";  
300 - else  
301 - {  
302 - if(!$classPDO && !$classSQLite3 && $this->getVersion()==3)  
303 - echo "It appears that your database is of SQLite version 3 but your installation of PHP does not contain the necessary extensions to handle this version. To fix the problem, either delete the database and allow ".PROJECT." to create it automatically or recreate it manually as SQLite version 2.";  
304 - else if(!$classSQLiteDatabase && $this->getVersion()==2)  
305 - echo "It appears that your database is of SQLite version 2 but your installation of PHP does not contain the necessary extensions to handle this version. To fix the problem, either delete the database and allow ".PROJECT." to create it automatically or recreate it manually as SQLite version 3.";  
306 - else  
307 - echo "The problem cannot be diagnosed properly. Please email me at daneiracleous@gmail.com with your database as an attachment and the contents of this error message. It may be that your database is simply not a valid SQLite database, but this is not certain.";  
308 - }  
309 - echo "</div><br/>";  
310 - }  
311 -  
312 - public function __destruct()  
313 - {  
314 - if($this->db)  
315 - $this->close();  
316 - }  
317 -  
318 - //get the exact PHP extension being used for SQLite  
319 - public function getType()  
320 - {  
321 - return $this->type;  
322 - }  
323 -  
324 - //get the name of the database  
325 - public function getName()  
326 - {  
327 - return $this->data["name"];  
328 - }  
329 -  
330 - //get the filename of the database  
331 - public function getPath()  
332 - {  
333 - return $this->data["path"];  
334 - }  
335 -  
336 - //get the version of the database  
337 - public function getVersion()  
338 - {  
339 - if(file_exists($this->data['path'])) //make sure file exists before getting its contents  
340 - {  
341 - $content = strtolower(file_get_contents($this->data['path'], NULL, NULL, 0, 40)); //get the first 40 characters of the database file  
342 - $p = strpos($content, "** this file contains an sqlite 2"); //this text is at the beginning of every SQLite2 database  
343 - if($p!==false) //the text is found - this is version 2  
344 - return 2;  
345 - else  
346 - return 3;  
347 - }  
348 - else //return -1 to indicate that it does not exist and needs to be created  
349 - {  
350 - return -1;  
351 - }  
352 - }  
353 -  
354 - //get the size of the database  
355 - public function getSize()  
356 - {  
357 - return round(filesize($this->data["path"])*0.0009765625, 1)." Kb";  
358 - }  
359 -  
360 - //get the last modified time of database  
361 - public function getDate()  
362 - {  
363 - return date("g:ia \o\\n F j, Y", filemtime($this->data["path"]));  
364 - }  
365 -  
366 - //get number of affected rows from last query  
367 - public function getAffectedRows()  
368 - {  
369 - if($this->type=="PDO")  
370 - return $this->lastResult->rowCount();  
371 - else if($this->type=="SQLite3")  
372 - return $this->db->changes();  
373 - else if($this->type=="SQLiteDatabase")  
374 - return $this->db->changes();  
375 - }  
376 -  
377 - public function close()  
378 - {  
379 - if($this->type=="PDO")  
380 - $this->db = NULL;  
381 - else if($this->type=="SQLite3")  
382 - $this->db->close();  
383 - else if($this->type=="SQLiteDatabase")  
384 - $this->db = NULL;  
385 - }  
386 -  
387 - public function beginTransaction()  
388 - {  
389 - $this->query("BEGIN");  
390 - }  
391 -  
392 - public function commitTransaction()  
393 - {  
394 - $this->query("COMMIT");  
395 - }  
396 -  
397 - public function rollbackTransaction()  
398 - {  
399 - $this->query("ROLLBACK");  
400 - }  
401 -  
402 - //generic query wrapper  
403 - public function query($query, $ignoreAlterCase=false)  
404 - {  
405 - if(strtolower(substr(ltrim($query),0,5))=='alter' && $ignoreAlterCase==false) //this query is an ALTER query - call the necessary function  
406 - {  
407 - $queryparts = preg_split("/[\s]+/", $query, 4, PREG_SPLIT_NO_EMPTY);  
408 - $tablename = $queryparts[2];  
409 - $alterdefs = $queryparts[3];  
410 - //echo $query;  
411 - $result = $this->alterTable($tablename, $alterdefs);  
412 - }  
413 - else //this query is normal - proceed as normal  
414 - $result = $this->db->query($query);  
415 - if(!$result)  
416 - return NULL;  
417 - $this->lastResult = $result;  
418 - return $result;  
419 - }  
420 -  
421 - //wrapper for an INSERT and returns the ID of the inserted row  
422 - public function insert($query)  
423 - {  
424 - $result = $this->query($query);  
425 - if($this->type=="PDO")  
426 - return $this->db->lastInsertId();  
427 - else if($this->type=="SQLite3")  
428 - return $this->db->lastInsertRowID();  
429 - else if($this->type=="SQLiteDatabase")  
430 - return $this->db->lastInsertRowid();  
431 - }  
432 -  
433 - //returns an array for SELECT  
434 - public function select($query, $mode="both")  
435 - {  
436 - $result = $this->query($query);  
437 - if(!$result) //make sure the result is valid  
438 - return NULL;  
439 - if($this->type=="PDO")  
440 - {  
441 - if($mode=="assoc")  
442 - $mode = PDO::FETCH_ASSOC;  
443 - else if($mode=="num")  
444 - $mode = PDO::FETCH_NUM;  
445 - else  
446 - $mode = PDO::FETCH_BOTH;  
447 - return $result->fetch($mode);  
448 - }  
449 - else if($this->type=="SQLite3")  
450 - {  
451 - if($mode=="assoc")  
452 - $mode = SQLITE3_ASSOC;  
453 - else if($mode=="num")  
454 - $mode = SQLITE3_NUM;  
455 - else  
456 - $mode = SQLITE3_BOTH;  
457 - return $result->fetchArray($mode);  
458 - }  
459 - else if($this->type=="SQLiteDatabase")  
460 - {  
461 - if($mode=="assoc")  
462 - $mode = SQLITE_ASSOC;  
463 - else if($mode=="num")  
464 - $mode = SQLITE_NUM;  
465 - else  
466 - $mode = SQLITE_BOTH;  
467 - return $result->fetch($mode);  
468 - }  
469 - }  
470 -  
471 - //returns an array of arrays after doing a SELECT  
472 - public function selectArray($query, $mode="both")  
473 - {  
474 - $result = $this->query($query);  
475 - if(!$result) //make sure the result is valid  
476 - return NULL;  
477 - if($this->type=="PDO")  
478 - {  
479 - if($mode=="assoc")  
480 - $mode = PDO::FETCH_ASSOC;  
481 - else if($mode=="num")  
482 - $mode = PDO::FETCH_NUM;  
483 - else  
484 - $mode = PDO::FETCH_BOTH;  
485 - return $result->fetchAll($mode);  
486 - }  
487 - else if($this->type=="SQLite3")  
488 - {  
489 - if($mode=="assoc")  
490 - $mode = SQLITE3_ASSOC;  
491 - else if($mode=="num")  
492 - $mode = SQLITE3_NUM;  
493 - else  
494 - $mode = SQLITE3_BOTH;  
495 - $arr = array();  
496 - $i = 0;  
497 - while($res = $result->fetchArray($mode))  
498 - {  
499 - $arr[$i] = $res;  
500 - $i++;  
501 - }  
502 - return $arr;  
503 - }  
504 - else if($this->type=="SQLiteDatabase")  
505 - {  
506 - if($mode=="assoc")  
507 - $mode = SQLITE_ASSOC;  
508 - else if($mode=="num")  
509 - $mode = SQLITE_NUM;  
510 - else  
511 - $mode = SQLITE_BOTH;  
512 - return $result->fetchAll($mode);  
513 - }  
514 - }  
515 -  
516 - //function that is called for an alter table statement in a query  
517 - //code borrowed with permission from http://code.jenseng.com/db/  
518 - public function alterTable($table, $alterdefs)  
519 - {  
520 - if($alterdefs != '')  
521 - {  
522 - $tempQuery = "SELECT sql,name,type FROM sqlite_master WHERE tbl_name = '".$table."' ORDER BY type DESC";  
523 - $result = $this->query($tempQuery);  
524 - $resultArr = $this->selectArray($tempQuery);  
525 -  
526 - if(sizeof($resultArr)>0)  
527 - {  
528 - $row = $this->select($tempQuery); //table sql  
529 - $tmpname = 't'.time();  
530 - $origsql = trim(preg_replace("/[\s]+/", " ", str_replace(",", ", ",preg_replace("/[\(]/", "( ", $row['sql'], 1))));  
531 - $createtemptableSQL = 'CREATE TEMPORARY '.substr(trim(preg_replace("'".$table."'", $tmpname, $origsql, 1)), 6);  
532 - $createindexsql = array();  
533 - $i = 0;  
534 - $defs = preg_split("/[,]+/",$alterdefs, -1, PREG_SPLIT_NO_EMPTY);  
535 - $prevword = $table;  
536 - $oldcols = preg_split("/[,]+/", substr(trim($createtemptableSQL), strpos(trim($createtemptableSQL), '(')+1), -1, PREG_SPLIT_NO_EMPTY);  
537 - $newcols = array();  
538 - for($i=0; $i<sizeof($oldcols); $i++)  
539 - {  
540 - $colparts = preg_split("/[\s]+/", $oldcols[$i], -1, PREG_SPLIT_NO_EMPTY);  
541 - $oldcols[$i] = $colparts[0];  
542 - $newcols[$colparts[0]] = $colparts[0];  
543 - }  
544 - $newcolumns = '';  
545 - $oldcolumns = '';  
546 - reset($newcols);  
547 - while(list($key, $val) = each($newcols))  
548 - {  
549 - $newcolumns .= ($newcolumns?', ':'').$val;  
550 - $oldcolumns .= ($oldcolumns?', ':'').$key;  
551 - }  
552 - $copytotempsql = 'INSERT INTO '.$tmpname.'('.$newcolumns.') SELECT '.$oldcolumns.' FROM '.$table;  
553 - $dropoldsql = 'DROP TABLE '.$table;  
554 - $createtesttableSQL = $createtemptableSQL;  
555 - foreach($defs as $def)  
556 - {  
557 - $defparts = preg_split("/[\s]+/", $def,-1, PREG_SPLIT_NO_EMPTY);  
558 - $action = strtolower($defparts[0]);  
559 - switch($action)  
560 - {  
561 - case 'add':  
562 - if(sizeof($defparts) <= 2)  
563 - return false;  
564 - $createtesttableSQL = substr($createtesttableSQL, 0, strlen($createtesttableSQL)-1).',';  
565 - for($i=1;$i<sizeof($defparts);$i++)  
566 - $createtesttableSQL.=' '.$defparts[$i];  
567 - $createtesttableSQL.=')';  
568 - break;  
569 - case 'change':  
570 - if(sizeof($defparts) <= 3)  
571 - {  
572 - return false;  
573 - }  
574 - if($severpos = strpos($createtesttableSQL,' '.$defparts[1].' '))  
575 - {  
576 - if($newcols[$defparts[1]] != $defparts[1])  
577 - return false;  
578 - $newcols[$defparts[1]] = $defparts[2];  
579 - $nextcommapos = strpos($createtesttableSQL,',',$severpos);  
580 - $insertval = '';  
581 - for($i=2;$i<sizeof($defparts);$i++)  
582 - $insertval.=' '.$defparts[$i];  
583 - if($nextcommapos)  
584 - $createtesttableSQL = substr($createtesttableSQL,0,$severpos).$insertval.substr($createtesttableSQL,$nextcommapos);  
585 - else  
586 - $createtesttableSQL = substr($createtesttableSQL,0,$severpos-(strpos($createtesttableSQL,',')?0:1)).$insertval.')';  
587 - }  
588 - else  
589 - return false;  
590 - break;  
591 - case 'drop':  
592 - if(sizeof($defparts) < 2)  
593 - return false;  
594 - if($severpos = strpos($createtesttableSQL,' '.$defparts[1].' '))  
595 - {  
596 - $nextcommapos = strpos($createtesttableSQL,',',$severpos);  
597 - if($nextcommapos)  
598 - $createtesttableSQL = substr($createtesttableSQL,0,$severpos).substr($createtesttableSQL,$nextcommapos + 1);  
599 - else  
600 - $createtesttableSQL = substr($createtesttableSQL,0,$severpos-(strpos($createtesttableSQL,',')?0:1) - 1).')';  
601 - unset($newcols[$defparts[1]]);  
602 - }  
603 - else  
604 - return false;  
605 - break;  
606 - default:  
607 - return false;  
608 - }  
609 - $prevword = $defparts[sizeof($defparts)-1];  
610 - }  
611 - //this block of code generates a test table simply to verify that the columns specifed are valid in an sql statement  
612 - //this ensures that no reserved words are used as columns, for example  
613 - $tempResult = $this->query($createtesttableSQL);  
614 - if(!$tempResult)  
615 - return false;  
616 - $droptempsql = 'DROP TABLE '.$tmpname;  
617 - $tempResult = $this->query($droptempsql);  
618 - //end block  
619 -  
620 - $createnewtableSQL = 'CREATE '.substr(trim(preg_replace("'".$tmpname."'", $table, $createtesttableSQL, 1)), 17);  
621 - $newcolumns = '';  
622 - $oldcolumns = '';  
623 - reset($newcols);  
624 - while(list($key,$val) = each($newcols))  
625 - {  
626 - $newcolumns .= ($newcolumns?', ':'').$val;  
627 - $oldcolumns .= ($oldcolumns?', ':'').$key;  
628 - }  
629 - $copytonewsql = 'INSERT INTO '.$table.'('.$newcolumns.') SELECT '.$oldcolumns.' FROM '.$tmpname;  
630 -  
631 - $this->query($createtemptableSQL); //create temp table  
632 - $this->query($copytotempsql); //copy to table  
633 - $this->query($dropoldsql); //drop old table  
634 -  
635 - $this->query($createnewtableSQL); //recreate original table  
636 - $this->query($copytonewsql); //copy back to original table  
637 - $this->query($droptempsql); //drop temp table  
638 - }  
639 - else  
640 - {  
641 - return false;  
642 - }  
643 - return true;  
644 - }  
645 - }  
646 -  
647 - //multiple query execution  
648 - public function multiQuery($query)  
649 - {  
650 - if($this->type=="PDO")  
651 - {  
652 - $this->db->exec($query);  
653 - }  
654 - else if($this->type=="SQLite3")  
655 - {  
656 - $this->db->exec($query);  
657 - }  
658 - else  
659 - {  
660 - $this->db->queryExec($query);  
661 - }  
662 - }  
663 -  
664 - //get number of rows in table  
665 - public function numRows($table)  
666 - {  
667 - $result = $this->select("SELECT Count(*) FROM ".$table);  
668 - return $result[0];  
669 - }  
670 -  
671 - //correctly escape a string to be injected into an SQL query  
672 - public function quote($value)  
673 - {  
674 - if($this->type=="PDO")  
675 - {  
676 - return $this->db->quote($value);  
677 - }  
678 - else if($this->type=="SQLite3")  
679 - {  
680 - return $this->db->escapeString($value);  
681 - }  
682 - else  
683 - {  
684 - return "'".$value."'";  
685 - }  
686 - }  
687 -  
688 - //correctly format a string value from a table before showing it  
689 - public function formatString($value)  
690 - {  
691 - return htmlspecialchars(stripslashes($value));  
692 - }  
693 -  
694 - //import  
695 - public function import($query)  
696 - {  
697 - $this->multiQuery($query);  
698 - }  
699 -  
700 - //export  
701 - public function export($tables, $drop, $structure, $data, $transaction, $comments)  
702 - {  
703 - if($comments)  
704 - {  
705 - echo "----\r\n";  
706 - echo "-- phpLiteAdmin database dump (http://phpliteadmin.googlecode.com)\r\n";  
707 - echo "-- phpLiteAdmin version: ".VERSION."\r\n";  
708 - echo "-- Exported on ".date('M jS, Y, h:i:sA')."\r\n";  
709 - echo "-- Database file: ".$this->getPath()."\r\n";  
710 - echo "----\r\n";  
711 - }  
712 - $query = "SELECT * FROM sqlite_master WHERE type='table' OR type='index' ORDER BY type DESC";  
713 - $result = $this->selectArray($query);  
714 -  
715 - //iterate through each table  
716 - for($i=0; $i<sizeof($result); $i++)  
717 - {  
718 - $valid = false;  
719 - for($j=0; $j<sizeof($tables); $j++)  
720 - {  
721 - if($result[$i]['tbl_name']==$tables[$j])  
722 - $valid = true;  
723 - }  
724 - if($valid)  
725 - {  
726 - if($drop)  
727 - {  
728 - if($comments)  
729 - {  
730 - echo "\r\n----\r\n";  
731 - if($result[$i]['type']=="table")  
732 - echo "-- Drop table for ".$result[$i]['tbl_name']."\r\n";  
733 - else  
734 - echo "-- Drop index for ".$result[$i]['name']."\r\n";  
735 - echo "----\r\n";  
736 - }  
737 - if($result[$i]['type']=="table")  
738 - echo "DROP TABLE '".$result[$i]['tbl_name']."';\r\n";  
739 - else  
740 - echo "DROP INDEX '".$result[$i]['name']."';\r\n";  
741 - }  
742 - if($structure)  
743 - {  
744 - if($comments)  
745 - {  
746 - echo "\r\n----\r\n";  
747 - if($result[$i]['type']=="table")  
748 - echo "-- Table structure for ".$result[$i]['tbl_name']."\r\n";  
749 - else  
750 - echo "-- Structure for index ".$result[$i]['name']." on table ".$result[$i]['tbl_name']."\r\n";  
751 - echo "----\r\n";  
752 - }  
753 - echo $result[$i]['sql'].";\r\n";  
754 - }  
755 - if($data && $result[$i]['type']=="table")  
756 - {  
757 - $query = "SELECT * FROM ".$result[$i]['tbl_name'];  
758 - $arr = $this->selectArray($query, "assoc");  
759 -  
760 - if($comments)  
761 - {  
762 - echo "\r\n----\r\n";  
763 - echo "-- Data dump for ".$result[$i]['tbl_name'].", a total of ".sizeof($arr)." rows\r\n";  
764 - echo "----\r\n";  
765 - }  
766 - $query = "PRAGMA table_info('".$result[$i]['tbl_name']."')";  
767 - $temp = $this->selectArray($query);  
768 - $cols = array();  
769 - $vals = array();  
770 - for($z=0; $z<sizeof($temp); $z++)  
771 - $cols[$z] = $temp[$z][1];  
772 - for($z=0; $z<sizeof($arr); $z++)  
773 - {  
774 - for($y=0; $y<sizeof($cols); $y++)  
775 - {  
776 - if(!isset($vals[$z]))  
777 - $vals[$z] = array();  
778 - $vals[$z][$cols[$y]] = $this->quote($arr[$z][$cols[$y]]);  
779 - }  
780 - }  
781 - if($transaction)  
782 - echo "BEGIN TRANSACTION;\r\n";  
783 - for($j=0; $j<sizeof($vals); $j++)  
784 - echo "INSERT INTO ".$result[$i]['tbl_name']." (".implode(",", $cols).") VALUES (".implode(",", $vals[$j]).");\r\n";  
785 - if($transaction)  
786 - echo "COMMIT;\r\n";  
787 - }  
788 - }  
789 - }  
790 - }  
791 -}  
792 -  
793 -$auth = new Authorization(); //create authorization object  
794 -if(isset($_POST['logout'])) //user has attempted to log out  
795 - $auth->revoke();  
796 -else if(isset($_POST['login']) || isset($_POST['proc_login'])) //user has attempted to log in  
797 -{  
798 - $_POST['login'] = true;  
799 -  
800 - if($_POST['password']==SYSTEMPASSWORD) //make sure passwords match before granting authorization  
801 - {  
802 - if(isset($_POST['remember']))  
803 - $auth->grant(true);  
804 - else  
805 - $auth->grant(false);  
806 - }  
807 -}  
808 -  
809 -//user is downloading the exported database file  
810 -if(isset($_POST['export']))  
811 -{  
812 - header('Content-Type: text/sql');  
813 - header('Content-Disposition: attachment; filename="'.$_POST['filename'].'.'.$_POST['export_type'].'";');  
814 - if(isset($_POST['tables']))  
815 - $tables = $_POST['tables'];  
816 - else  
817 - {  
818 - $tables = array();  
819 - $tables[0] = $_POST['single_table'];  
820 - }  
821 - $drop = isset($_POST['drop']);  
822 - $structure = isset($_POST['structure']);  
823 - $data = isset($_POST['data']);  
824 - $transaction = isset($_POST['transaction']);  
825 - $comments = isset($_POST['comments']);  
826 - $db = new Database($databases[$_SESSION[COOKIENAME.'currentDB']]);  
827 - echo $db->export($tables, $drop, $structure, $data, $transaction, $comments);  
828 - exit();  
829 -}  
830 -  
831 -//user is importing a file  
832 -if(isset($_POST['import']))  
833 -{  
834 - $data = file_get_contents($_FILES["file"]["tmp_name"]);  
835 - $db = new Database($databases[$_SESSION[COOKIENAME.'currentDB']]);  
836 - $db->import($data);  
837 -}  
838 -  
839 -// here begins the HTML.  
840 -?>  
841 -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
842 -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
843 -<head>  
844 -<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />  
845 -<title><?php echo PROJECT ?></title>  
846 -  
847 -<?php  
848 -if(!file_exists("phpliteadmin.css")) //only use the inline stylesheet if an external one does not exist  
849 -{  
850 -?>  
851 -<!-- begin the customizable stylesheet/theme -->  
852 -<style type="text/css">  
853 -/* overall styles for entire page */  
854 -body  
855 -{  
856 - margin: 0px;  
857 - padding: 0px;  
858 - font-family: Arial, Helvetica, sans-serif;  
859 - font-size: 14px;  
860 - color: #000000;  
861 - background-color: #e0ebf6;  
862 -}  
863 -/* general styles for hyperlink */  
864 -a  
865 -{  
866 - color: #03F;  
867 - text-decoration: none;  
868 - cursor :pointer;  
869 -}  
870 -hr  
871 -{  
872 - height: 1px;  
873 - border: 0;  
874 - color: #bbb;  
875 - background-color: #bbb;  
876 - width: 100%;  
877 -}  
878 -a:hover  
879 -{  
880 - color: #06F;  
881 -}  
882 -/* logo text containing name of project */  
883 -h1  
884 -{  
885 - margin: 0px;  
886 - padding: 5px;  
887 - font-size: 24px;  
888 - background-color: #f3cece;  
889 - text-align: center;  
890 - margin-bottom: 10px;  
891 - color: #000;  
892 - border-top-left-radius:5px;  
893 - border-top-right-radius:5px;  
894 - -moz-border-radius-topleft:5px;  
895 - -moz-border-radius-topright:5px;  
896 -}  
897 -/* version text within the logo */  
898 -h1 #version  
899 -{  
900 - color: #000000;  
901 - font-size: 16px;  
902 -}  
903 -/* logo text within logo */  
904 -h1 #logo  
905 -{  
906 - color:#000;  
907 -}  
908 -/* general header for various views */  
909 -h2  
910 -{  
911 - margin:0px;  
912 - padding:0px;  
913 - font-size:14px;  
914 - margin-bottom:20px;  
915 -}  
916 -/* input buttons and areas for entering text */  
917 -input, select, textarea  
918 -{  
919 - font-family:Arial, Helvetica, sans-serif;  
920 - background-color:#eaeaea;  
921 - color:#03F;  
922 - border-color:#03F;  
923 - border-style:solid;  
924 - border-width:1px;  
925 - margin:5px;  
926 - border-radius:5px;  
927 - -moz-border-radius:5px;  
928 - padding:3px;  
929 -}  
930 -/* just input buttons */  
931 -input.btn  
932 -{  
933 - cursor:pointer;  
934 -}  
935 -input.btn:hover  
936 -{  
937 - background-color:#ccc;  
938 -}  
939 -/* general styles for hyperlink */  
940 -fieldset  
941 -{  
942 - padding:15px;  
943 - border-color:#03F;  
944 - border-width:1px;  
945 - border-style:solid;  
946 - border-radius:5px;  
947 - -moz-border-radius:5px;  
948 - background-color:#f9f9f9;  
949 -}  
950 -/* outer div that holds everything */  
951 -#container  
952 -{  
953 - padding:10px;  
954 -}  
955 -/* div of left box with log, list of databases, etc. */  
956 -#leftNav  
957 -{  
958 - float:left;  
959 - width:250px;  
960 - padding:0px;  
961 - border-color:#03F;  
962 - border-width:1px;  
963 - border-style:solid;  
964 - background-color:#FFF;  
965 - padding-bottom:15px;  
966 - border-radius:5px;  
967 - -moz-border-radius:5px;  
968 -}  
969 -/* div holding the content to the right of the leftNav */  
970 -#content  
971 -{  
972 - overflow:hidden;  
973 - padding-left:10px;  
974 -}  
975 -/* div holding the login fields */  
976 -#loginBox  
977 -{  
978 - width:500px;  
979 - margin-left:auto;  
980 - margin-right:auto;  
981 - margin-top:50px;  
982 - border-color:#03F;  
983 - border-width:1px;  
984 - border-style:solid;  
985 - background-color:#FFF;  
986 - border-radius:5px;  
987 - -moz-border-radius:5px;  
988 -}  
989 -/* div under tabs with tab-specific content */  
990 -#main  
991 -{  
992 - border-color:#03F;  
993 - border-width:1px;  
994 - border-style:solid;  
995 - padding:15px;  
996 - overflow:auto;  
997 - background-color:#FFF;  
998 - border-bottom-left-radius:5px;  
999 - border-bottom-right-radius:5px;  
1000 - border-top-right-radius:5px;  
1001 - -moz-border-radius-bottomleft:5px;  
1002 - -moz-border-radius-bottomright:5px;  
1003 - -moz-border-radius-topright:5px;  
1004 -}  
1005 -/* odd-numbered table rows */  
1006 -.td1  
1007 -{  
1008 - background-color:#f9e3e3;  
1009 - text-align:right;  
1010 - font-size:12px;  
1011 - padding-left:10px;  
1012 - padding-right:10px;  
1013 -}  
1014 -/* even-numbered table rows */  
1015 -.td2  
1016 -{  
1017 - background-color:#f3cece;  
1018 - text-align:right;  
1019 - font-size:12px;  
1020 - padding-left:10px;  
1021 - padding-right:10px;  
1022 -}  
1023 -/* table column headers */  
1024 -.tdheader  
1025 -{  
1026 - border-color:#03F;  
1027 - border-width:1px;  
1028 - border-style:solid;  
1029 - font-weight:bold;  
1030 - font-size:12px;  
1031 - padding-left:10px;  
1032 - padding-right:10px;  
1033 - background-color:#e0ebf6;  
1034 - border-radius:5px;  
1035 - -moz-border-radius:5px;  
1036 -}  
1037 -/* div holding the confirmation text of certain actions */  
1038 -.confirm  
1039 -{  
1040 - border-color:#03F;  
1041 - border-width:1px;  
1042 - border-style:dashed;  
1043 - padding:15px;  
1044 - background-color:#e0ebf6;  
1045 -}  
1046 -/* tab navigation for each table */  
1047 -.tab  
1048 -{  
1049 - display:block;  
1050 - padding:5px;  
1051 - padding-right:8px;  
1052 - padding-left:8px;  
1053 - border-color:#03F;  
1054 - border-width:1px;  
1055 - border-style:solid;  
1056 - margin-right:5px;  
1057 - float:left;  
1058 - border-bottom-style:none;  
1059 - position:relative;  
1060 - top:1px;  
1061 - padding-bottom:4px;  
1062 - background-color:#eaeaea;  
1063 - border-top-left-radius:5px;  
1064 - border-top-right-radius:5px;  
1065 - -moz-border-radius-topleft:5px;  
1066 - -moz-border-radius-topright:5px;  
1067 -}  
1068 -/* pressed state of tab */  
1069 -.tab_pressed  
1070 -{  
1071 - display:block;  
1072 - padding:5px;  
1073 - padding-right:8px;  
1074 - padding-left:8px;  
1075 - border-color:#03F;  
1076 - border-width:1px;  
1077 - border-style:solid;  
1078 - margin-right:5px;  
1079 - float:left;  
1080 - border-bottom-style:none;  
1081 - position:relative;  
1082 - top:1px;  
1083 - background-color:#FFF;  
1084 - cursor:default;  
1085 - border-top-left-radius:5px;  
1086 - border-top-right-radius:5px;  
1087 - -moz-border-radius-topleft:5px;  
1088 - -moz-border-radius-topright:5px;  
1089 -}  
1090 -/* tooltip styles */  
1091 -#tt  
1092 -{  
1093 - position:absolute;  
1094 - display:block;  
1095 -}  
1096 -#tttop  
1097 -{  
1098 - display:block;  
1099 - height:5px;  
1100 - margin-left:5px;  
1101 - overflow:hidden  
1102 -}  
1103 -#ttcont  
1104 -{  
1105 - display:block;  
1106 - padding:2px 12px 3px 7px;  
1107 - margin-left:5px;  
1108 - background:#f3cece;  
1109 - color:#333  
1110 -}  
1111 -#ttbot  
1112 -{  
1113 - display:block;  
1114 - height:5px;  
1115 - margin-left:5px;  
1116 - overflow:hidden  
1117 -}  
1118 -</style>  
1119 -<!-- end the customizable stylesheet/theme -->  
1120 -<?php  
1121 -}  
1122 -else //an external stylesheet exists - import it  
1123 -{  
1124 - echo "<link href='phpliteadmin.css' rel='stylesheet' type='text/css' />";  
1125 -}  
1126 -?>  
1127 -<!-- JavaScript Support -->  
1128 -<script type="text/javascript">  
1129 -//makes sure autoincrement can only be selected when integer type is selected  
1130 -function toggleAutoincrement(i)  
1131 -{  
1132 - var type = document.getElementById(i+'_type');  
1133 - var autoincrement = document.getElementById(i+'_autoincrement');  
1134 - if(type.value=="INTEGER")  
1135 - autoincrement.disabled = false;  
1136 - else  
1137 - {  
1138 - autoincrement.disabled = true;  
1139 - autoincrement.checked = false;  
1140 - }  
1141 -}  
1142 -//finds and checks all checkboxes for all rows on the Browse or Structure tab for a table  
1143 -function checkAll(field)  
1144 -{  
1145 - var i=0;  
1146 - while(document.getElementById('check_'+i)!=undefined)  
1147 - {  
1148 - document.getElementById('check_'+i).checked = true;  
1149 - i++;  
1150 - }  
1151 -}  
1152 -//finds and unchecks all checkboxes for all rows on the Browse or Structure tab for a table  
1153 -function uncheckAll(field)  
1154 -{  
1155 - var i=0;  
1156 - while(document.getElementById('check_'+i)!=undefined)  
1157 - {  
1158 - document.getElementById('check_'+i).checked = false;  
1159 - i++;  
1160 - }  
1161 -}  
1162 -//unchecks the ignore checkbox if user has typed something into one of the fields for adding new rows  
1163 -function changeIgnore(area, e)  
1164 -{  
1165 - if(area.value!="")  
1166 - document.getElementById(e).checked = false;  
1167 -}  
1168 -//moves fields from select menu into query textarea for SQL tab  
1169 -function moveFields()  
1170 -{  
1171 - var fields = document.getElementById("fieldcontainer");  
1172 - var selected = new Array();  
1173 - for(var i=0; i<fields.options.length; i++)  
1174 - if(fields.options[i].selected)  
1175 - selected.push(fields.options[i].value);  
1176 - for(var i=0; i<selected.length; i++)  
1177 - insertAtCaret("queryval", "`"+selected[i]+"`");  
1178 -}  
1179 -//helper function for moveFields  
1180 -function insertAtCaret(areaId,text)  
1181 -{  
1182 - var txtarea = document.getElementById(areaId);  
1183 - var scrollPos = txtarea.scrollTop;  
1184 - var strPos = 0;  
1185 - var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? "ff" : (document.selection ? "ie" : false ));  
1186 - if(br=="ie")  
1187 - {  
1188 - txtarea.focus();  
1189 - var range = document.selection.createRange();  
1190 - range.moveStart ('character', -txtarea.value.length);  
1191 - strPos = range.text.length;  
1192 - }  
1193 - else if(br=="ff")  
1194 - strPos = txtarea.selectionStart;  
1195 -  
1196 - var front = (txtarea.value).substring(0,strPos);  
1197 - var back = (txtarea.value).substring(strPos,txtarea.value.length);  
1198 - txtarea.value=front+text+back;  
1199 - strPos = strPos + text.length;  
1200 - if(br=="ie")  
1201 - {  
1202 - txtarea.focus();  
1203 - var range = document.selection.createRange();  
1204 - range.moveStart ('character', -txtarea.value.length);  
1205 - range.moveStart ('character', strPos);  
1206 - range.moveEnd ('character', 0);  
1207 - range.select();  
1208 - }  
1209 - else if(br=="ff")  
1210 - {  
1211 - txtarea.selectionStart = strPos;  
1212 - txtarea.selectionEnd = strPos;  
1213 - txtarea.focus();  
1214 - }  
1215 - txtarea.scrollTop = scrollPos;  
1216 -}  
1217 -//tooltip help feature  
1218 -var tooltip=function()  
1219 -{  
1220 - var id = 'tt';  
1221 - var top = 3;  
1222 - var left = 3;  
1223 - var maxw = 300;  
1224 - var speed = 10;  
1225 - var timer = 20;  
1226 - var endalpha = 95;  
1227 - var alpha = 0;  
1228 - var tt,t,c,b,h;  
1229 - var ie = document.all ? true : false;  
1230 - return{  
1231 - show:function(v,w)  
1232 - {  
1233 - if(tt == null)  
1234 - {  
1235 - tt = document.createElement('div');  
1236 - tt.setAttribute('id',id);  
1237 - t = document.createElement('div');  
1238 - t.setAttribute('id',id + 'top');  
1239 - c = document.createElement('div');  
1240 - c.setAttribute('id',id + 'cont');  
1241 - b = document.createElement('div');  
1242 - b.setAttribute('id',id + 'bot');  
1243 - tt.appendChild(t);  
1244 - tt.appendChild(c);  
1245 - tt.appendChild(b);  
1246 - document.body.appendChild(tt);  
1247 - tt.style.opacity = 0;  
1248 - tt.style.filter = 'alpha(opacity=0)';  
1249 - document.onmousemove = this.pos;  
1250 - }  
1251 - tt.style.display = 'block';  
1252 - c.innerHTML = v;  
1253 - tt.style.width = w ? w + 'px' : 'auto';  
1254 - if(!w && ie)  
1255 - {  
1256 - t.style.display = 'none';  
1257 - b.style.display = 'none';  
1258 - tt.style.width = tt.offsetWidth;  
1259 - t.style.display = 'block';  
1260 - b.style.display = 'block';  
1261 - }  
1262 - if(tt.offsetWidth > maxw)  
1263 - tt.style.width = maxw + 'px'  
1264 - h = parseInt(tt.offsetHeight) + top;  
1265 - clearInterval(tt.timer);  
1266 - tt.timer = setInterval(function(){tooltip.fade(1)},timer);  
1267 - },  
1268 - pos:function(e)  
1269 - {  
1270 - var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;  
1271 - var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;  
1272 - tt.style.top = (u - h) + 'px';  
1273 - tt.style.left = (l + left) + 'px';  
1274 - },  
1275 - fade:function(d)  
1276 - {  
1277 - var a = alpha;  
1278 - if((a != endalpha && d == 1) || (a != 0 && d == -1))  
1279 - {  
1280 - var i = speed;  
1281 - if(endalpha - a < speed && d == 1)  
1282 - i = endalpha - a;  
1283 - else if(alpha < speed && d == -1)  
1284 - i = a;  
1285 - alpha = a + (i * d);  
1286 - tt.style.opacity = alpha * .01;  
1287 - tt.style.filter = 'alpha(opacity=' + alpha + ')';  
1288 - }  
1289 - else  
1290 - {  
1291 - clearInterval(tt.timer);  
1292 - if(d == -1)  
1293 - tt.style.display = 'none';  
1294 - }  
1295 - },  
1296 - hide:function()  
1297 - {  
1298 - clearInterval(tt.timer);  
1299 - tt.timer = setInterval(function()  
1300 - {  
1301 - tooltip.fade(-1)  
1302 - },timer);  
1303 - }  
1304 - };  
1305 -}();  
1306 -</script>  
1307 -</head>  
1308 -<body>  
1309 -<?php  
1310 -if(ini_get("register_globals")) //check whether register_globals is turned on - if it is, we need to not continue  
1311 -{  
1312 - echo "<div class='confirm' style='margin:20px;'>";  
1313 - echo "It appears that the PHP directive, 'register_globals' is enabled. This is bad. You need to disable it before continuing.";  
1314 - echo "</div>";  
1315 - exit();  
1316 -}  
1317 -  
1318 -if(!$auth->isAuthorized()) //user is not authorized - display the login screen  
1319 -{  
1320 - echo "<div id='loginBox'>";  
1321 - echo "<h1><span id='logo'>".PROJECT."</span> <span id='version'>v".VERSION."</span></h1>";  
1322 - echo "<div style='padding:15px; text-align:center;'>";  
1323 - if(isset($_POST['login']))  
1324 - echo "<span style='color:red;'>Incorrect password.</span><br/><br/>";  
1325 - echo "<form action='".PAGE."' method='post'>";  
1326 - echo "Password: <input type='password' name='password'/><br/>";  
1327 - echo "<input type='checkbox' name='remember' value='yes' checked='checked'/> Remember me<br/><br/>";  
1328 - echo "N&atilde;o sabe a senha? Veja no arquivo i3geo/pacotes/phpliteadmin/senha.php<br><br>";  
1329 - echo "Al&eacute;m de saber a senha, voc&ecirc; precisa ser um administrador cadastrado em i3geo/ms_configura.php<br><br>";  
1330 - echo "<input type='submit' value='Log In' name='login' class='btn'/>";  
1331 - echo "<input type='hidden' name='proc_login' value='true' />";  
1332 - echo "</form>";  
1333 - echo "</div>";  
1334 - echo "</div>";  
1335 - echo "<br/>";  
1336 - echo "<div style='text-align:center;'>";  
1337 - $endTimeTot = microtime(true);  
1338 - $timeTot = round(($endTimeTot - $startTimeTot), 4);  
1339 - echo "<span style='font-size:11px;'>Powered by <a href='http://phpliteadmin.googlecode.com' target='_blank' style='font-size:11px;'>".PROJECT."</a> | Page generated in ".$timeTot." seconds.</span>";  
1340 - echo "</div>";  
1341 -}  
1342 -else //user is authorized - display the main application  
1343 -{  
1344 - if(!isset($_SESSION[COOKIENAME.'currentDB']))  
1345 - $_SESSION[COOKIENAME.'currentDB'] = 0;  
1346 - //set the current database to the first in the array (default)  
1347 - if(sizeof($databases)>0)  
1348 - $currentDB = $databases[0];  
1349 - else //the database array is empty - show error and halt execution  
1350 - {  
1351 - echo "<div class='confirm' style='margin:20px;'>";  
1352 - echo "Error: you have not specified any databases to manage.";  
1353 - echo "</div><br/>";  
1354 - exit();  
1355 - }  
1356 -  
1357 - if(isset($_POST['database_switch'])) //user is switching database with drop-down menu  
1358 - {  
1359 - $_SESSION[COOKIENAME."currentDB"] = $_POST['database_switch'];  
1360 - $currentDB = $databases[$_SESSION[COOKIENAME.'currentDB']];  
1361 - }  
1362 - else if(isset($_GET['switchdb']))  
1363 - {  
1364 - $_SESSION[COOKIENAME."currentDB"] = $_GET['switchdb'];  
1365 - $currentDB = $databases[$_SESSION[COOKIENAME.'currentDB']];  
1366 - }  
1367 - if(isset($_SESSION[COOKIENAME.'currentDB']))  
1368 - $currentDB = $databases[$_SESSION[COOKIENAME.'currentDB']];  
1369 -  
1370 - //create the objects  
1371 - $db = new Database($currentDB); //create the Database object  
1372 -  
1373 - //switch board for various operations a user could have requested - these actions are invisible and produce no output  
1374 - if(isset($_GET['action']) && isset($_GET['confirm']))  
1375 - {  
1376 - switch($_GET['action'])  
1377 - {  
1378 - //table actions  
1379 - /////////////////////////////////////////////// create table  
1380 - case "table_create":  
1381 - $num = intval($_POST['rows']);  
1382 - $name = $_POST['tablename'];  
1383 - $query = "CREATE TABLE ".$name."(";  
1384 - for($i=0; $i<$num; $i++)  
1385 - {  
1386 - if($_POST[$i.'_field']!="")  
1387 - {  
1388 - $query .= $_POST[$i.'_field']." ";  
1389 - $query .= $_POST[$i.'_type']." ";  
1390 - if(isset($_POST[$i.'_primarykey']))  
1391 - $query .= "PRIMARY KEY ";  
1392 - if(isset($_POST[$i.'_notnull']))  
1393 - $query .= "NOT NULL ";  
1394 - if($_POST[$i.'_defaultvalue']!="")  
1395 - {  
1396 - if($_POST[$i.'_type']=="INTEGER")  
1397 - $query .= "default ".$_POST[$i.'_defaultvalue']." ";  
1398 - else  
1399 - $query .= "default '".$_POST[$i.'_defaultvalue']."' ";  
1400 - }  
1401 - $query = substr($query, 0, sizeof($query)-2);  
1402 - $query .= ", ";  
1403 - }  
1404 - }  
1405 - $query = substr($query, 0, sizeof($query)-3);  
1406 - $query .= ")";  
1407 - $result = $db->query($query);  
1408 - if(!$result)  
1409 - $error = true;  
1410 - $completed = "Table '".$_POST['tablename']."' has been created.<br/><span style='font-size:11px;'>".$query."</span>";  
1411 - break;  
1412 - /////////////////////////////////////////////// empty table  
1413 - case "table_empty":  
1414 - $query = "DELETE FROM ".$_POST['tablename'];  
1415 - $result = $db->query($query);  
1416 - if(!$result)  
1417 - $error = true;  
1418 - $query = "VACUUM";  
1419 - $result = $db->query($query);  
1420 - if(!$result)  
1421 - $error = true;  
1422 - $completed = "Table '".$_POST['tablename']."' has been emptied.<br/><span style='font-size:11px;'>".$query."</span>";  
1423 - break;  
1424 - /////////////////////////////////////////////// drop table  
1425 - case "table_drop":  
1426 - $query = "DROP TABLE ".$_POST['tablename'];  
1427 - $db->query($query);  
1428 - $completed = "Table '".$_POST['tablename']."' has been dropped.";  
1429 - break;  
1430 - /////////////////////////////////////////////// rename table  
1431 - case "table_rename":  
1432 - $query = "ALTER TABLE ".$_POST['oldname']." RENAME TO ".$_POST['newname'];  
1433 - if($db->getVersion()==3)  
1434 - $result = $db->query($query, true);  
1435 - else  
1436 - $result = $db->query($query, false);  
1437 - if(!$result)  
1438 - $error = true;  
1439 - $completed = "Table '".$_POST['oldname']."' has been renamed to '".$_POST['newname']."'.<br/><span style='font-size:11px;'>".$query."</span>";  
1440 - break;  
1441 - //row actions  
1442 - /////////////////////////////////////////////// create row  
1443 - case "row_create":  
1444 - $completed = "";  
1445 - $num = $_POST['numRows'];  
1446 - $fields = explode(":", $_POST['fields']);  
1447 - $z = 0;  
1448 - for($i=0; $i<$num; $i++)  
1449 - {  
1450 - if(!isset($_POST[$i.":ignore"]))  
1451 - {  
1452 - $query = "INSERT INTO ".$_GET['table']." (";  
1453 - for($j=0; $j<sizeof($fields); $j++)  
1454 - {  
1455 - $query .= $fields[$j].",";  
1456 - }  
1457 - $query = substr($query, 0, sizeof($query)-2);  
1458 - $query .= ") VALUES (";  
1459 - for($j=0; $j<sizeof($fields); $j++)  
1460 - {  
1461 - $value = $_POST[$i.":".$fields[$j]];  
1462 - $function = $_POST["function_".$i."_".$fields[$j]];  
1463 - if($function!="")  
1464 - $query .= $function."(";  
1465 - if($value=="")  
1466 - $query .= "NULL";  
1467 - else  
1468 - $query .= $db->quote($value);  
1469 - if($function!="")  
1470 - $query .= ")";  
1471 - $query .= ",";  
1472 - }  
1473 - $query = substr($query, 0, sizeof($query)-2);  
1474 - $query .= ")";  
1475 - $result = $db->query($query);  
1476 - if(!$result)  
1477 - $error = true;  
1478 - $completed .= "<span style='font-size:11px;'>".$query."</span><br/>";  
1479 - $z++;  
1480 - }  
1481 - }  
1482 - $completed = $z." row(s) inserted.<br/><br/>".$completed;  
1483 - break;  
1484 - /////////////////////////////////////////////// delete row  
1485 - case "row_delete":  
1486 - $pks = explode(":", $_GET['pk']);  
1487 - $str = $pks[0];  
1488 - $query = "DELETE FROM ".$_GET['table']." WHERE ROWID = ".$pks[0];  
1489 - for($i=1; $i<sizeof($pks); $i++)  
1490 - {  
1491 - $str .= ", ".$pks[$i];  
1492 - $query .= " OR ROWID = ".$pks[$i];  
1493 - }  
1494 - $result = $db->query($query);  
1495 - if(!$result)  
1496 - $error = true;  
1497 - $completed = sizeof($pks)." row(s) deleted.<br/><span style='font-size:11px;'>".$query."</span>";  
1498 - break;  
1499 - /////////////////////////////////////////////// edit row  
1500 - case "row_edit":  
1501 - $pks = explode(":", $_GET['pk']);  
1502 - $fields = explode(":", $_POST['fieldArray']);  
1503 -  
1504 - $completed = sizeof($pks)." row(s) affected.<br/><br/>";  
1505 -  
1506 - for($i=0; $i<sizeof($pks); $i++)  
1507 - {  
1508 - $query = "UPDATE ".$_GET['table']." SET ";  
1509 - for($j=0; $j<sizeof($fields); $j++)  
1510 - {  
1511 - $function = $_POST["function_".$pks[$i]."_".$fields[$j]];  
1512 - $query .= $fields[$j]."=";  
1513 - if($function!="")  
1514 - $query .= $function."(";  
1515 - $query .= $db->quote($_POST[$pks[$i].":".$fields[$j]]);  
1516 - if($function!="")  
1517 - $query .= ")";  
1518 - $query .= ", ";  
1519 - }  
1520 - $query = substr($query, 0, sizeof($query)-3);  
1521 - $query .= " WHERE ROWID = ".$pks[$i];  
1522 - $result = $db->query($query);  
1523 - if(!$result)  
1524 - {  
1525 - $error = true;  
1526 - }  
1527 - $completed .= "<span style='font-size:11px;'>".$query."</span><br/>";  
1528 - }  
1529 - break;  
1530 - //column actions  
1531 - /////////////////////////////////////////////// create column  
1532 - case "column_create":  
1533 - $num = intval($_POST['rows']);  
1534 - for($i=0; $i<$num; $i++)  
1535 - {  
1536 - if($_POST[$i.'_field']!="")  
1537 - {  
1538 - $query = "ALTER TABLE ".$_GET['table']." ADD ".$_POST[$i.'_field']." ";  
1539 - $query .= $_POST[$i.'_type']." ";  
1540 - if(isset($_POST[$i.'_primarykey']))  
1541 - $query .= "PRIMARY KEY ";  
1542 - if(isset($_POST[$i.'_notnull']))  
1543 - $query .= "NOT NULL ";  
1544 - if($_POST[$i.'_defaultvalue']!="")  
1545 - {  
1546 - if($_POST[$i.'_type']=="INTEGER")  
1547 - $query .= "DEFAULT ".$_POST[$i.'_defaultvalue']." ";  
1548 - else  
1549 - $query .= "DEFAULT '".$_POST[$i.'_defaultvalue']."' ";  
1550 - }  
1551 - if($db->getVersion()==3)  
1552 - $result = $db->query($query, true);  
1553 - else  
1554 - $result = $db->query($query, false);  
1555 - if(!$result)  
1556 - $error = true;  
1557 - }  
1558 - }  
1559 - $completed = "Table '".$_GET['table']."' has been altered successfully.";  
1560 - break;  
1561 - /////////////////////////////////////////////// delete column  
1562 - case "column_delete":  
1563 - $pks = explode(":", $_GET['pk']);  
1564 - $str = $pks[0];  
1565 - $query = "ALTER TABLE ".$_GET['table']." DROP ".$pks[0];  
1566 - for($i=1; $i<sizeof($pks); $i++)  
1567 - {  
1568 - $str .= ", ".$pks[$i];  
1569 - $query .= ", DROP ".$pks[$i];  
1570 - }  
1571 - $result = $db->query($query);  
1572 - if(!$result)  
1573 - $error = true;  
1574 - $completed = "Table '".$_GET['table']."' has been altered successfully.";  
1575 - break;  
1576 - /////////////////////////////////////////////// edit column  
1577 - case "column_edit":  
1578 - $query = "ALTER TABLE ".$_GET['table']." CHANGE ".$_POST['field_old']." ".$_POST['field']." ".$_POST['type'];  
1579 - $result = $db->query($query);  
1580 - if(!$result)  
1581 - $error = true;  
1582 - $completed = "Table '".$_GET['table']."' has been altered successfully.";  
1583 - break;  
1584 - /////////////////////////////////////////////// delete index  
1585 - case "index_delete":  
1586 - $query = "DROP INDEX ".$_GET['pk'];  
1587 - $result = $db->query($query);  
1588 - if(!$result)  
1589 - $error = true;  
1590 - $completed = "Index '".$_GET['pk']."' deleted.<br/><span style='font-size:11px;'>".$query."</span>";  
1591 - break;  
1592 - /////////////////////////////////////////////// create index  
1593 - case "index_create":  
1594 - $num = $_POST['num'];  
1595 -  
1596 - $str = "CREATE ";  
1597 - if($_POST['duplicate']=="no")  
1598 - $str .= "UNIQUE ";  
1599 - $str .= "INDEX ".$_POST['name']." ON ".$_GET['table']." (";  
1600 - $str .= $_POST['0_field'].$_POST['0_order'];  
1601 - for($i=1; $i<$num; $i++)  
1602 - {  
1603 - if($_POST[$i.'_field']!="--Ignore--")  
1604 - $str .= ", ".$_POST[$i.'_field'].$_POST[$i.'_order'];  
1605 - }  
1606 - $str .= ")";  
1607 - $query = $str;  
1608 - $result = $db->query($query);  
1609 - if(!$result)  
1610 - $error = true;  
1611 - $completed = "Index created.<br/><span style='font-size:11px;'>".$query."</span>";  
1612 - break;  
1613 - }  
1614 - }  
1615 -  
1616 - echo "<div id='container'>";  
1617 - echo "<div id='leftNav'>";  
1618 - echo "<h1>";  
1619 - echo "<a href='".PAGE."'>";  
1620 - echo "<span id='logo'>".PROJECT."</span> <span id='version'>v".VERSION."</span>";  
1621 - echo "</a>";  
1622 - echo "</h1>";  
1623 - echo "<fieldset style='margin:15px;'><legend><b>Change Database</b></legend>";  
1624 - if(sizeof($databases)<10) //if there aren't a lot of databases, just show them as a list of links instead of drop down menu  
1625 - {  
1626 - for($i=0; $i<sizeof($databases); $i++)  
1627 - {  
1628 - if($i==$_SESSION[COOKIENAME.'currentDB'])  
1629 - echo "<a href='".PAGE."?switchdb=".$i."' style='text-decoration:underline;'>".$databases[$i]['name']."</a>";  
1630 - else  
1631 - echo "<a href='".PAGE."?switchdb=".$i."'>".$databases[$i]['name']."</a>";  
1632 - if($i<sizeof($databases)-1)  
1633 - echo "<br/>";  
1634 - }  
1635 - }  
1636 - else //there are a lot of databases - show a drop down menu  
1637 - {  
1638 - echo "<form action='".PAGE."' method='post'>";  
1639 - echo "<select name='database_switch'>";  
1640 - for($i=0; $i<sizeof($databases); $i++)  
1641 - {  
1642 - if($i==$_SESSION[COOKIENAME.'currentDB'])  
1643 - echo "<option value='".$i."' selected='selected'>".$databases[$i]['name']."</option>";  
1644 - else  
1645 - echo "<option value='".$i."'>".$databases[$i]['name']."</option>";  
1646 - }  
1647 - echo "</select> ";  
1648 - echo "<input type='submit' value='Go' class='btn'>";  
1649 - echo "</form>";  
1650 - }  
1651 - echo "</fieldset>";  
1652 - echo "<fieldset style='margin:15px;'><legend>";  
1653 - echo "<a href='".PAGE."'";  
1654 - if(!isset($_GET['table']))  
1655 - echo " style='text-decoration:underline;'";  
1656 - echo ">".$currentDB['name']."</a>";  
1657 - echo "</legend>";  
1658 - //Display list of tables  
1659 - $query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name";  
1660 - $result = $db->selectArray($query);  
1661 - $j=0;  
1662 - for($i=0; $i<sizeof($result); $i++)  
1663 - {  
1664 - if(substr($result[$i]['name'], 0, 7)!="sqlite_" && $result[$i]['name']!="")  
1665 - {  
1666 - echo "<a href='".PAGE."?action=row_view&table=".$result[$i]['name']."'";  
1667 - if(isset($_GET['table']) && $_GET['table']==$result[$i]['name'])  
1668 - echo " style='text-decoration:underline;'";  
1669 - echo ">".$result[$i]['name']."</a><br/>";  
1670 - $j++;  
1671 - }  
1672 - }  
1673 - if($j==0)  
1674 - echo "No tables in database.";  
1675 - echo "</fieldset>";  
1676 - echo "<div style='text-align:center;'>";  
1677 - echo "<form action='".PAGE."' method='post'/>";  
1678 - echo "<input type='submit' value='Log Out' name='logout' class='btn'/>";  
1679 - echo "</form>";  
1680 - echo "</div>";  
1681 - echo "</div>";  
1682 - echo "<div id='content'>";  
1683 -  
1684 - //breadcrumb navigation  
1685 - echo "<a href='".PAGE."'>".$currentDB['name']."</a>";  
1686 - if(isset($_GET['table']))  
1687 - echo " &rarr; <a href='".PAGE."?table=".$_GET['table']."&action=row_view'>".$_GET['table']."</a>";  
1688 - echo "<br/><br/>";  
1689 -  
1690 - //user has performed some action so show the resulting message  
1691 - if(isset($_GET['confirm']))  
1692 - {  
1693 - echo "<div id='main'>";  
1694 - echo "<div class='confirm'>";  
1695 - if(isset($error) && $error) //an error occured during the action, so show an error message  
1696 - echo "An error occured. This may be a bug that needs to be reported at <a href='http://code.google.com/p/phpliteadmin/issues/list' target='_blank'>code.google.com/p/phpliteadmin/issues/list</a>";  
1697 - else //action was performed successfully - show success message  
1698 - echo $completed;  
1699 - echo "</div>";  
1700 - if($_GET['action']=="row_delete" || $_GET['action']=="row_create" || $_GET['action']=="row_edit")  
1701 - echo "<br/><br/><a href='".PAGE."?table=".$_GET['table']."&action=row_view'>Return</a>";  
1702 - else if($_GET['action']=="column_create" || $_GET['action']=="column_delete" || $_GET['action']=="column_edit" || $_GET['action']=="index_create" || $_GET['action']=="index_delete")  
1703 - echo "<br/><br/><a href='".PAGE."?table=".$_GET['table']."&action=column_view'>Return</a>";  
1704 - else  
1705 - echo "<br/><br/><a href='".PAGE."'>Return</a>";  
1706 - echo "</div>";  
1707 - }  
1708 -  
1709 - //show the various tab views for a table  
1710 - if(!isset($_GET['confirm']) && isset($_GET['table']) && isset($_GET['action']) && ($_GET['action']=="table_export" || $_GET['action']=="table_import" || $_GET['action']=="table_sql" || $_GET['action']=="row_view" || $_GET['action']=="row_create" || $_GET['action']=="column_view" || $_GET['action']=="table_rename" || $_GET['action']=="table_search"))  
1711 - {  
1712 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=row_view' ";  
1713 - if($_GET['action']=="row_view")  
1714 - echo "class='tab_pressed'";  
1715 - else  
1716 - echo "class='tab'";  
1717 - echo ">Browse</a>";  
1718 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=column_view' ";  
1719 - if($_GET['action']=="column_view")  
1720 - echo "class='tab_pressed'";  
1721 - else  
1722 - echo "class='tab'";  
1723 - echo ">Structure</a>";  
1724 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=table_sql' ";  
1725 - if($_GET['action']=="table_sql")  
1726 - echo "class='tab_pressed'";  
1727 - else  
1728 - echo "class='tab'";  
1729 - echo ">SQL</a>";  
1730 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=table_search' ";  
1731 - if($_GET['action']=="table_search")  
1732 - echo "class='tab_pressed'";  
1733 - else  
1734 - echo "class='tab'";  
1735 - echo ">Search</a>";  
1736 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=row_create' ";  
1737 - if($_GET['action']=="row_create")  
1738 - echo "class='tab_pressed'";  
1739 - else  
1740 - echo "class='tab'";  
1741 - echo ">Insert</a>";  
1742 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=table_export' ";  
1743 - if($_GET['action']=="table_export")  
1744 - echo "class='tab_pressed'";  
1745 - else  
1746 - echo "class='tab'";  
1747 - echo ">Export</a>";  
1748 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=table_import' ";  
1749 - if($_GET['action']=="table_import")  
1750 - echo "class='tab_pressed'";  
1751 - else  
1752 - echo "class='tab'";  
1753 - echo ">Import</a>";  
1754 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=table_rename' ";  
1755 - if($_GET['action']=="table_rename")  
1756 - echo "class='tab_pressed'";  
1757 - else  
1758 - echo "class='tab'";  
1759 - echo ">Rename</a>";  
1760 - echo "<a href='".PAGE."?action=table_empty&table=".$_GET['table']."' ";  
1761 - echo "class='tab' style='color:red;'";  
1762 - echo ">Empty</a>";  
1763 - echo "<a href='".PAGE."?action=table_drop&table=".$_GET['table']."' ";  
1764 - echo "class='tab' style='color:red;'";  
1765 - echo ">Drop</a>";  
1766 - echo "<div style='clear:both;'></div>";  
1767 - }  
1768 -  
1769 - //switch board for the page display  
1770 - if(isset($_GET['action']) && !isset($_GET['confirm']))  
1771 - {  
1772 - echo "<div id='main'>";  
1773 - switch($_GET['action'])  
1774 - {  
1775 - //table actions  
1776 - /////////////////////////////////////////////// create table  
1777 - case "table_create":  
1778 - echo "<h2>Creating new table: '".$_POST['tablename']."'</h2>";  
1779 - if($_POST['tablefields']=="" || intval($_POST['tablefields'])<=0)  
1780 - echo "You must specify the number of table fields.";  
1781 - else if($_POST['tablename']=="")  
1782 - echo "You must specify a table name.";  
1783 - else  
1784 - {  
1785 - $num = intval($_POST['tablefields']);  
1786 - $name = $_POST['tablename'];  
1787 - echo "<form action='".PAGE."?action=table_create&confirm=1' method='post'>";  
1788 - echo "<input type='hidden' name='tablename' value='".$name."'/>";  
1789 - echo "<input type='hidden' name='rows' value='".$num."'/>";  
1790 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
1791 - echo "<tr>";  
1792 - $headings = array("Field", "Type", "Primary Key", "Autoincrement", "Not NULL", "Default Value");  
1793 - for($k=0; $k<count($headings); $k++)  
1794 - echo "<td class='tdheader'>" . $headings[$k] . "</td>";  
1795 - echo "</tr>";  
1796 -  
1797 - for($i=0; $i<$num; $i++)  
1798 - {  
1799 - $tdWithClass = "<td class='td" . ($i%2 ? "1" : "2") . "'>";  
1800 - echo "<tr>";  
1801 - echo $tdWithClass;  
1802 - echo "<input type='text' name='".$i."_field' style='width:200px;'/>";  
1803 - echo "</td>";  
1804 - echo $tdWithClass;  
1805 - echo "<select name='".$i."_type' id='".$i."_type' onchange='toggleAutoincrement(".$i.");'>";  
1806 - $types = unserialize(DATATYPES);  
1807 - for($z=0; $z<sizeof($types); $z++)  
1808 - echo "<option value='".$types[$z]."'>".$types[$z]."</option>";  
1809 - echo "</select>";  
1810 - echo "</td>";  
1811 - echo $tdWithClass;  
1812 - echo "<input type='checkbox' name='".$i."_primarykey'/> Yes";  
1813 - echo "</td>";  
1814 - echo $tdWithClass;  
1815 - echo "<input type='checkbox' name='".$i."_autoincrement' id='".$i."_autoincrement'/> Yes";  
1816 - echo "</td>";  
1817 - echo $tdWithClass;  
1818 - echo "<input type='checkbox' name='".$i."_notnull'/> Yes";  
1819 - echo "</td>";  
1820 - echo $tdWithClass;  
1821 - echo "<input type='text' name='".$i."_defaultvalue' style='width:100px;'/>";  
1822 - echo "</td>";  
1823 - echo "</tr>";  
1824 - }  
1825 - echo "<tr>";  
1826 - echo "<td class='tdheader' style='text-align:right;' colspan='6'>";  
1827 - echo "<input type='submit' value='Create' class='btn'/> ";  
1828 - echo "<a href='".PAGE."'>Cancel</a>";  
1829 - echo "</td>";  
1830 - echo "</tr>";  
1831 - echo "</table>";  
1832 - echo "</form>";  
1833 - }  
1834 - break;  
1835 - /////////////////////////////////////////////// perform SQL query on table  
1836 - case "table_sql":  
1837 - $isSelect = false;  
1838 - if(isset($_POST['query']) && $_POST['query']!="")  
1839 - {  
1840 - $delimiter = $_POST['delimiter'];  
1841 - $queryStr = stripslashes($_POST['queryval']);  
1842 - $query = explode($delimiter, $queryStr); //explode the query string into individual queries based on the delimiter  
1843 -  
1844 - for($i=0; $i<sizeof($query); $i++) //iterate through the queries exploded by the delimiter  
1845 - {  
1846 - if(str_replace(" ", "", str_replace("\n", "", str_replace("\r", "", $query[$i])))!="") //make sure this query is not an empty string  
1847 - {  
1848 - $startTime = microtime(true);  
1849 - if(strpos(strtolower($query[$i]), "select ")!==false)  
1850 - {  
1851 - $isSelect = true;  
1852 - $result = $db->selectArray($query[$i], "assoc");  
1853 - }  
1854 - else  
1855 - {  
1856 - $isSelect = false;  
1857 - $result = $db->query($query[$i]);  
1858 - }  
1859 - $endTime = microtime(true);  
1860 - $time = round(($endTime - $startTime), 4);  
1861 -  
1862 - echo "<div class='confirm'>";  
1863 - echo "<b>";  
1864 - if($isSelect && $result)  
1865 - {  
1866 - if($isSelect)  
1867 - {  
1868 - $affected = sizeof($result);  
1869 - echo "Showing ".$affected." row(s). ";  
1870 - }  
1871 - else  
1872 - {  
1873 - $affected = $db->getAffectedRows();  
1874 - echo $affected." row(s) affected. ";  
1875 - }  
1876 - echo "(Query took ".$time." sec)</b><br/>";  
1877 - }  
1878 - else  
1879 - {  
1880 - echo "There is a problem with the syntax of your query ";  
1881 - echo "(Query was not executed)</b><br/>";  
1882 - }  
1883 - echo "<span style='font-size:11px;'>".$query[$i]."</span>";  
1884 - echo "</div><br/>";  
1885 - if($isSelect)  
1886 - {  
1887 - if(sizeof($result)>0)  
1888 - {  
1889 - $headers = array_keys($result[0]);  
1890 -  
1891 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
1892 - echo "<tr>";  
1893 - for($j=0; $j<sizeof($headers); $j++)  
1894 - {  
1895 - echo "<td class='tdheader'>";  
1896 - echo $headers[$j];  
1897 - echo "</td>";  
1898 - }  
1899 - echo "</tr>";  
1900 - for($j=0; $j<sizeof($result); $j++)  
1901 - {  
1902 - $tdWithClass = "<td class='td".($j%2 ? "1" : "2")."'>";  
1903 - echo "<tr>";  
1904 - for($z=0; $z<sizeof($headers); $z++)  
1905 - {  
1906 - echo $tdWithClass;  
1907 - echo $result[$j][$headers[$z]];  
1908 - echo "</td>";  
1909 - }  
1910 - echo "</tr>";  
1911 - }  
1912 - echo "</table><br/><br/>";  
1913 - }  
1914 - }  
1915 - }  
1916 - }  
1917 - }  
1918 - else  
1919 - {  
1920 - $delimiter = ";";  
1921 - $queryStr = "SELECT * FROM `".$_GET['table']."` WHERE 1";  
1922 - }  
1923 -  
1924 - echo "<fieldset>";  
1925 - echo "<legend><b>Run SQL query/queries on database '".$db->getName()."'</b></legend>";  
1926 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=table_sql' method='post'>";  
1927 - echo "<div style='float:left; width:70%;'>";  
1928 - echo "<textarea style='width:97%; height:300px;' name='queryval' id='queryval'>".$queryStr."</textarea>";  
1929 - echo "</div>";  
1930 - echo "<div style='float:left; width:28%; padding-left:10px;'>";  
1931 - echo "Fields<br/>";  
1932 - echo "<select multiple='multiple' style='width:100%;' id='fieldcontainer'>";  
1933 - $query = "PRAGMA table_info('".$_GET['table']."')";  
1934 - $result = $db->selectArray($query);  
1935 - for($i=0; $i<sizeof($result); $i++)  
1936 - {  
1937 - echo "<option value='".$result[$i][1]."'>".$result[$i][1]."</option>";  
1938 - }  
1939 - echo "</select>";  
1940 - echo "<input type='button' value='<<' onclick='moveFields();' class='btn'/>";  
1941 - echo "</div>";  
1942 - echo "<div style='clear:both;'></div>";  
1943 - echo "Delimiter <input type='text' name='delimiter' value='".$delimiter."' style='width:50px;'/> ";  
1944 - echo "<input type='submit' name='query' value='Go' class='btn'/>";  
1945 - echo "</form>";  
1946 - break;  
1947 - /////////////////////////////////////////////// empty table  
1948 - case "table_empty":  
1949 - echo "<form action='".PAGE."?action=table_empty&confirm=1' method='post'>";  
1950 - echo "<input type='hidden' name='tablename' value='".$_GET['table']."'/>";  
1951 - echo "<div class='confirm'>";  
1952 - echo "Are you sure you want to empty the table '".$_GET['table']."'?<br/><br/>";  
1953 - echo "<input type='submit' value='Confirm' class='btn'/> ";  
1954 - echo "<a href='".PAGE."'>Cancel</a>";  
1955 - echo "</div>";  
1956 - break;  
1957 - /////////////////////////////////////////////// drop table  
1958 - case "table_drop":  
1959 - echo "<form action='".PAGE."?action=table_drop&confirm=1' method='post'>";  
1960 - echo "<input type='hidden' name='tablename' value='".$_GET['table']."'/>";  
1961 - echo "<div class='confirm'>";  
1962 - echo "Are you sure you want to drop the table '".$_GET['table']."'?<br/><br/>";  
1963 - echo "<input type='submit' value='Confirm' class='btn'/> ";  
1964 - echo "<a href='".PAGE."'>Cancel</a>";  
1965 - echo "</div>";  
1966 - break;  
1967 - /////////////////////////////////////////////// export table  
1968 - case "table_export":  
1969 - echo "<form method='post' action='".PAGE."'>";  
1970 - echo "<fieldset style='float:left; width:260px; margin-right:20px;'><legend><b>Export</b></legend>";  
1971 - echo "<input type='hidden' value='".$_GET['table']."' name='single_table'/>";  
1972 - echo "<input type='radio' name='export_type' checked='checked' value='sql'/> SQL";  
1973 - echo "</fieldset>";  
1974 - echo "<fieldset style='float:left;'><legend><b>Options</b></legend>";  
1975 - echo "<input type='checkbox' checked='checked' name='structure'/> Export with structure [<a onmouseover='tooltip.show(\"Creates the queries to add the tables and their columns\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
1976 - echo "<input type='checkbox' checked='checked' name='data'/> Export with data [<a onmouseover='tooltip.show(\"Creates the queries to insert the table rows\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
1977 - echo "<input type='checkbox' name='drop'/> Add DROP TABLE [<a onmouseover='tooltip.show(\"Creates the queries to remove the tables before potentially adding them so that errors do not occur if they already exist\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
1978 - echo "<input type='checkbox' checked='checked' name='transaction'/> Add TRANSACTION [<a onmouseover='tooltip.show(\"Performs queries within transactions so that if an error occurs, the table is not returned to a partially incomplete and unusable state\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
1979 - echo "<input type='checkbox' checked='checked' name='comments'/> Comments [<a onmouseover='tooltip.show(\"Adds comments to the file to explain what is happening in each part of it\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
1980 - echo "</fieldset>";  
1981 - echo "<div style='clear:both;'></div>";  
1982 - echo "<br/><br/>";  
1983 - echo "<fieldset style='float:left;'><legend><b>Save As</b></legend>";  
1984 - echo "<input type='hidden' name='database_num' value='".$_SESSION[COOKIENAME.'currentDB']."'/>";  
1985 - echo "<input type='text' name='filename' value='".$db->getPath().".".$_GET['table'].".".date("n-j-y").".dump' style='width:400px;'/> <input type='submit' name='export' value='Export' class='btn'/>";  
1986 - echo "</fieldset>";  
1987 - echo "</form>";  
1988 - break;  
1989 - /////////////////////////////////////////////// import table  
1990 - case "table_import":  
1991 - if(isset($_POST['import']))  
1992 - {  
1993 - echo "<div class='confirm'>";  
1994 - echo "Import was successful.";  
1995 - echo "</div><br/>";  
1996 - }  
1997 - echo "<form method='post' action='".PAGE."?table=".$_GET['action']."&action=table_import' enctype='multipart/form-data'>";  
1998 - echo "<fieldset><legend><b>File to import</b></legend>";  
1999 - echo "<input type='radio' name='export_type' checked='checked' value='sql'/> SQL";  
2000 - echo "<br/><br/>";  
2001 - echo "<input type='file' value='Choose File' name='file' style='background-color:transparent; border-style:none;'/> <input type='submit' value='Import' name='import' class='btn'/>";  
2002 - echo "</fieldset>";  
2003 - break;  
2004 - /////////////////////////////////////////////// rename table  
2005 - case "table_rename":  
2006 - echo "<form action='".PAGE."?action=table_rename&confirm=1' method='post'>";  
2007 - echo "<input type='hidden' name='oldname' value='".$_GET['table']."'/>";  
2008 - echo "Rename table '".$_GET['table']."' to <input type='text' name='newname' style='width:200px;'/> <input type='submit' value='Rename' name='rename' class='btn'/>";  
2009 - echo "</form>";  
2010 - break;  
2011 - /////////////////////////////////////////////// search table  
2012 - case "table_search":  
2013 - if(isset($_GET['done']))  
2014 - {  
2015 - $query = "PRAGMA table_info('".$_GET['table']."')";  
2016 - $result = $db->selectArray($query);  
2017 - $str = "";  
2018 - $j = 0;  
2019 - $arr = array();  
2020 - for($i=0; $i<sizeof($result); $i++)  
2021 - {  
2022 - $field = $result[$i][1];  
2023 - $operator = $_POST[$field.":operator"];  
2024 - $value = $_POST[$field];  
2025 - if($value!="" || $operator=="!= ''" || $operator=="= ''")  
2026 - {  
2027 - if($operator=="= ''" || $operator=="!= ''")  
2028 - $arr[$j] .= $field." ".$operator;  
2029 - else  
2030 - $arr[$j] .= $field." ".$operator." ".$db->quote($value);  
2031 - $j++;  
2032 - }  
2033 - }  
2034 - $query = "SELECT * FROM ".$_GET['table'];  
2035 - if(sizeof($arr)>0)  
2036 - {  
2037 - $query .= " WHERE ".$arr[0];  
2038 - for($i=1; $i<sizeof($arr); $i++)  
2039 - {  
2040 - $query .= " AND ".$arr[$i];  
2041 - }  
2042 - }  
2043 - $startTime = microtime(true);  
2044 - $result = $db->selectArray($query, "assoc");  
2045 - $endTime = microtime(true);  
2046 - $time = round(($endTime - $startTime), 4);  
2047 -  
2048 - echo "<div class='confirm'>";  
2049 - echo "<b>";  
2050 - if($result)  
2051 - {  
2052 - $affected = sizeof($result);  
2053 - echo "Showing ".$affected." row(s). ";  
2054 - echo "(Query took ".$time." sec)</b><br/>";  
2055 - }  
2056 - else  
2057 - {  
2058 - echo "There is a problem with the syntax of your query ";  
2059 - echo "(Query was not executed)</b><br/>";  
2060 - }  
2061 - echo "<span style='font-size:11px;'>".$query."</span>";  
2062 - echo "</div><br/>";  
2063 -  
2064 - if(sizeof($result)>0)  
2065 - {  
2066 - $headers = array_keys($result[0]);  
2067 -  
2068 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2069 - echo "<tr>";  
2070 - for($j=0; $j<sizeof($headers); $j++)  
2071 - {  
2072 - echo "<td class='tdheader'>";  
2073 - echo $headers[$j];  
2074 - echo "</td>";  
2075 - }  
2076 - echo "</tr>";  
2077 - for($j=0; $j<sizeof($result); $j++)  
2078 - {  
2079 - $tdWithClass = "<td class='td".($j%2 ? "1" : "2")."'>";  
2080 - echo "<tr>";  
2081 - for($z=0; $z<sizeof($headers); $z++)  
2082 - {  
2083 - echo $tdWithClass;  
2084 - echo $result[$j][$headers[$z]];  
2085 - echo "</td>";  
2086 - }  
2087 - echo "</tr>";  
2088 - }  
2089 - echo "</table><br/><br/>";  
2090 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=table_search'>Do Another Search</a>";  
2091 - }  
2092 - }  
2093 - else  
2094 - {  
2095 - $query = "PRAGMA table_info('".$_GET['table']."')";  
2096 - $result = $db->selectArray($query);  
2097 -  
2098 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=table_search&done=1' method='post'>";  
2099 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2100 - echo "<tr>";  
2101 - echo "<td class='tdheader'>Field</td>";  
2102 - echo "<td class='tdheader'>Type</td>";  
2103 - echo "<td class='tdheader'>Operator</td>";  
2104 - echo "<td class='tdheader'>Value</td>";  
2105 - echo "</tr>";  
2106 -  
2107 - for($i=0; $i<sizeof($result); $i++)  
2108 - {  
2109 - $field = $result[$i][1];  
2110 - $type = $result[$i][2];  
2111 - $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>";  
2112 - $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>";  
2113 - echo "<tr>";  
2114 - echo $tdWithClassLeft;  
2115 - echo $field;  
2116 - echo "</td>";  
2117 - echo $tdWithClassLeft;  
2118 - echo $type;  
2119 - echo "</td>";  
2120 - echo $tdWithClassLeft;  
2121 - echo "<select name='".$field.":operator'>";  
2122 - echo "<option value='='>=</option>";  
2123 - if($type=="INTEGER" || $type=="REAL")  
2124 - {  
2125 - echo "<option value='>'>></option>";  
2126 - echo "<option value='>='>>=</option>";  
2127 - echo "<option value='<'><</option>";  
2128 - echo "<option value='<='><=</option>";  
2129 - }  
2130 - else if($type=="TEXT" || $type=="BLOB")  
2131 - {  
2132 - echo "<option value='= '''>= ''</option>";  
2133 - echo "<option value='!= '''>!= ''</option>";  
2134 - }  
2135 - echo "<option value='!='>!=</option>";  
2136 - if($type=="TEXT" || $type=="BLOB")  
2137 - echo "<option value='LIKE' selected='selected'>LIKE</option>";  
2138 - else  
2139 - echo "<option value='LIKE'>LIKE</option>";  
2140 - echo "<option value='NOT LIKE'>NOT LIKE</option>";  
2141 - echo "</select>";  
2142 - echo "</td>";  
2143 - echo $tdWithClassLeft;  
2144 - if($type=="INTEGER" || $type=="REAL" || $type=="NULL")  
2145 - echo "<input type='text' name='".$field."'/>";  
2146 - else  
2147 - echo "<textarea name='".$field."' wrap='hard' rows='1' cols='60'></textarea>";  
2148 - echo "</td>";  
2149 - echo "</tr>";  
2150 - }  
2151 - echo "<tr>";  
2152 - echo "<td class='tdheader' style='text-align:right;' colspan='4'>";  
2153 - echo "<input type='submit' value='Search' class='btn'/>";  
2154 - echo "</td>";  
2155 - echo "</tr>";  
2156 - echo "</table>";  
2157 - echo "</form>";  
2158 - }  
2159 - break;  
2160 - //row actions  
2161 - /////////////////////////////////////////////// view row  
2162 - case "row_view":  
2163 - if(!isset($_POST['startRow']))  
2164 - $_POST['startRow'] = 0;  
2165 -  
2166 - if(isset($_POST['numRows']))  
2167 - $_SESSION[COOKIENAME.'numRows'] = $_POST['numRows'];  
2168 -  
2169 - if(!isset($_SESSION[COOKIENAME.'numRows']))  
2170 - $_SESSION[COOKIENAME.'numRows'] = 30;  
2171 -  
2172 - if(isset($_SESSION[COOKIENAME.'currentTable']) && $_SESSION[COOKIENAME.'currentTable']!=$_GET['table'])  
2173 - {  
2174 - unset($_SESSION[COOKIENAME.'sort']);  
2175 - unset($_SESSION[COOKIENAME.'order']);  
2176 - }  
2177 -  
2178 - $query = "SELECT Count(*) FROM ".$_GET['table'];  
2179 - $rowCount = $db->select($query);  
2180 - $rowCount = intval($rowCount[0]);  
2181 - $lastPage = intval($rowCount / $_SESSION[COOKIENAME.'numRows']);  
2182 - $remainder = intval($rowCount % $_SESSION[COOKIENAME.'numRows']);  
2183 - if($remainder==0)  
2184 - $remainder = $_SESSION[COOKIENAME.'numRows'];  
2185 -  
2186 - echo "<div style='overflow:hidden;'>";  
2187 - //previous button  
2188 - if($_POST['startRow']>0)  
2189 - {  
2190 - echo "<div style='float:left; overflow:hidden;'>";  
2191 - echo "<form action='".PAGE."?action=row_view&table=".$_GET['table']."' method='post'>";  
2192 - echo "<input type='hidden' name='startRow' value='0'/>";  
2193 - echo "<input type='hidden' name='numRows' value='".$_SESSION[COOKIENAME.'numRows']."'/> ";  
2194 - echo "<input type='submit' value='&larr;&larr;' name='previous' class='btn'/> ";  
2195 - echo "</form>";  
2196 - echo "</div>";  
2197 - echo "<div style='float:left; overflow:hidden; margin-right:20px;'>";  
2198 - echo "<form action='".PAGE."?action=row_view&table=".$_GET['table']."' method='post'>";  
2199 - echo "<input type='hidden' name='startRow' value='".intval($_POST['startRow']-$_SESSION[COOKIENAME.'numRows'])."'/>";  
2200 - echo "<input type='hidden' name='numRows' value='".$_SESSION[COOKIENAME.'numRows']."'/> ";  
2201 - echo "<input type='submit' value='&larr;' name='previous_full' class='btn'/> ";  
2202 - echo "</form>";  
2203 - echo "</div>";  
2204 - }  
2205 -  
2206 - //show certain number buttons  
2207 - echo "<div style='float:left; overflow:hidden;'>";  
2208 - echo "<form action='".PAGE."?action=row_view&table=".$_GET['table']."' method='post'>";  
2209 - echo "<input type='submit' value='Show : ' name='show' class='btn'/> ";  
2210 - echo "<input type='text' name='numRows' style='width:50px;' value='".$_SESSION[COOKIENAME.'numRows']."'/> ";  
2211 - echo "row(s) starting from record # ";  
2212 - if(intval($_POST['startRow']+$_SESSION[COOKIENAME.'numRows']) < $rowCount)  
2213 - echo "<input type='text' name='startRow' style='width:90px;' value='".intval($_POST['startRow']+$_SESSION[COOKIENAME.'numRows'])."'/>";  
2214 - else  
2215 - echo "<input type='text' name='startRow' style='width:90px;' value='0'/>";  
2216 - echo "</form>";  
2217 - echo "</div>";  
2218 -  
2219 - //next button  
2220 - if(intval($_POST['startRow']+$_SESSION[COOKIENAME.'numRows'])<$rowCount)  
2221 - {  
2222 - echo "<div style='float:left; overflow:hidden; margin-left:20px; '>";  
2223 - echo "<form action='".PAGE."?action=row_view&table=".$_GET['table']."' method='post'>";  
2224 - echo "<input type='hidden' name='startRow' value='".intval($_POST['startRow']+$_SESSION[COOKIENAME.'numRows'])."'/>";  
2225 - echo "<input type='hidden' name='numRows' value='".$_SESSION[COOKIENAME.'numRows']."'/> ";  
2226 - echo "<input type='submit' value='&rarr;' name='next' class='btn'/> ";  
2227 - echo "</form>";  
2228 - echo "</div>";  
2229 - echo "<div style='float:left; overflow:hidden;'>";  
2230 - echo "<form action='".PAGE."?action=row_view&table=".$_GET['table']."' method='post'>";  
2231 - echo "<input type='hidden' name='startRow' value='".intval($rowCount-$remainder)."'/>";  
2232 - echo "<input type='hidden' name='numRows' value='".$_SESSION[COOKIENAME.'numRows']."'/> ";  
2233 - echo "<input type='submit' value='&rarr;&rarr;' name='next_full' class='btn'/> ";  
2234 - echo "</form>";  
2235 - echo "</div>";  
2236 - }  
2237 - echo "<div style='clear:both;'></div>";  
2238 - echo "</div>";  
2239 -  
2240 - if(!isset($_GET['sort']))  
2241 - $_GET['sort'] = NULL;  
2242 - if(!isset($_GET['order']))  
2243 - $_GET['order'] = NULL;  
2244 -  
2245 - $table = $_GET['table'];  
2246 - $numRows = $_SESSION[COOKIENAME.'numRows'];  
2247 - $startRow = $_POST['startRow'];  
2248 - if(isset($_GET['sort']))  
2249 - {  
2250 - $_SESSION[COOKIENAME.'sort'] = $_GET['sort'];  
2251 - $_SESSION[COOKIENAME.'currentTable'] = $_GET['table'];  
2252 - }  
2253 - if(isset($_GET['order']))  
2254 - {  
2255 - $_SESSION[COOKIENAME.'order'] = $_GET['order'];  
2256 - $_SESSION[COOKIENAME.'currentTable'] = $_GET['table'];  
2257 - }  
2258 - $_SESSION[COOKIENAME.'numRows'] = $numRows;  
2259 - $query = "SELECT *, ROWID FROM ".$table;  
2260 - $queryDisp = "SELECT * FROM ".$table;  
2261 - $queryAdd = "";  
2262 - if(isset($_SESSION[COOKIENAME.'sort']))  
2263 - $queryAdd .= " ORDER BY ".$_SESSION[COOKIENAME.'sort'];  
2264 - if(isset($_SESSION[COOKIENAME.'order']))  
2265 - $queryAdd .= " ".$_SESSION[COOKIENAME.'order'];  
2266 - $queryAdd .= " LIMIT ".$startRow.", ".$numRows;  
2267 - $query .= $queryAdd;  
2268 - $queryDisp .= $queryAdd;  
2269 - $startTime = microtime(true);  
2270 - $arr = $db->selectArray($query);  
2271 - $endTime = microtime(true);  
2272 - $time = round(($endTime - $startTime), 4);  
2273 - $total = $db->numRows($table);  
2274 -  
2275 - if(sizeof($arr)>0)  
2276 - {  
2277 - echo "<br/><div class='confirm'>";  
2278 - echo "<b>Showing rows ".$startRow." - ".($startRow + sizeof($arr)-1)." (".$total." total, Query took ".$time." sec)</b><br/>";  
2279 - echo "<span style='font-size:11px;'>".$queryDisp."</span>";  
2280 - echo "</div><br/>";  
2281 -  
2282 - echo "<form action='".PAGE."?action=row_editordelete&table=".$table."' method='post' name='checkForm'>";  
2283 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2284 - $query = "PRAGMA table_info('".$table."')";  
2285 - $result = $db->selectArray($query);  
2286 - $rowidColumn = sizeof($result);  
2287 -  
2288 - echo "<tr>";  
2289 - echo "<td colspan='3'>";  
2290 - echo "</td>";  
2291 -  
2292 - for($i=0; $i<sizeof($result); $i++)  
2293 - {  
2294 - echo "<td class='tdheader'>";  
2295 - echo "<a href='".PAGE."?action=row_view&table=".$table."&sort=".$result[$i][1];  
2296 - if(isset($_SESSION[COOKIENAME.'sort']))  
2297 - $orderTag = ($_SESSION[COOKIENAME.'sort']==$result[$i][1] && $_SESSION[COOKIENAME.'order']=="ASC") ? "DESC" : "ASC";  
2298 - else  
2299 - $orderTag = "ASC";  
2300 - echo "&order=".$orderTag;  
2301 - echo "'>".$result[$i][1]."</a>";  
2302 - if(isset($_SESSION[COOKIENAME.'sort']) && $_SESSION[COOKIENAME.'sort']==$result[$i][1])  
2303 - echo (($_SESSION[COOKIENAME.'order']=="ASC") ? " <b>&uarr;</b>" : " <b>&darr;</b>");  
2304 - echo "</td>";  
2305 - }  
2306 - echo "</tr>";  
2307 -  
2308 - for($i=0; $i<sizeof($arr); $i++)  
2309 - {  
2310 - // -g-> $pk will always be the last column in each row of the array because we are doing a "SELECT *, ROWID FROM ..."  
2311 - $pk = $arr[$i][$rowidColumn];  
2312 - $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>";  
2313 - $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>";  
2314 - echo "<tr>";  
2315 - echo $tdWithClass;  
2316 - echo "<input type='checkbox' name='check[]' value='".$pk."' id='check_".$i."'/>";  
2317 - echo "</td>";  
2318 - echo $tdWithClass;  
2319 - // -g-> Here, we need to put the ROWID in as the link for both the edit and delete.  
2320 - echo "<a href='".PAGE."?table=".$table."&action=row_editordelete&pk=".$pk."&type=edit'>edit</a>";  
2321 - echo "</td>";  
2322 - echo $tdWithClass;  
2323 - echo "<a href='".PAGE."?table=".$table."&action=row_editordelete&pk=".$pk."&type=delete' style='color:red;'>delete</a>";  
2324 - echo "</td>";  
2325 - for($j=0; $j<sizeof($result); $j++)  
2326 - {  
2327 - if(strtolower($result[$j][2])=="integer" || strtolower($result[$j][2])=="float" || strtolower($result[$j][2])=="real")  
2328 - echo $tdWithClass;  
2329 - else  
2330 - echo $tdWithClassLeft;  
2331 - // -g-> although the inputs do not interpret HTML on the way "in", when we print the contents of the database the interpretation cannot be avoided.  
2332 - echo $db->formatString($arr[$i][$j]);  
2333 - echo "</td>";  
2334 - }  
2335 - echo "</tr>";  
2336 - }  
2337 - echo "</table>";  
2338 - echo "<a onclick='checkAll()'>Check All</a> / <a onclick='uncheckAll()'>Uncheck All</a> <i>With selected:</i> ";  
2339 - echo "<select name='type'>";  
2340 - echo "<option value='edit'>Edit</option>";  
2341 - echo "<option value='delete'>Delete</option>";  
2342 - echo "</select> ";  
2343 - echo "<input type='submit' value='Go' name='massGo' class='btn'/>";  
2344 - echo "</form>";  
2345 - }  
2346 - else if($rowCount>0)//no rows - do nothing  
2347 - {  
2348 - echo "<br/><br/>There are no rows in the table for the range you selected.";  
2349 - }  
2350 - else  
2351 - {  
2352 - echo "<br/><br/>This table is empty. <a href='".PAGE."?table=".$_GET['table']."&action=row_create'>Click here</a> to insert rows.";  
2353 - }  
2354 -  
2355 - break;  
2356 - /////////////////////////////////////////////// create row  
2357 - case "row_create":  
2358 - $fieldStr = "";  
2359 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=row_create' method='post'>";  
2360 - echo "Restart insertion with ";  
2361 - echo "<select name='num'>";  
2362 - for($i=1; $i<=40; $i++)  
2363 - {  
2364 - if(isset($_POST['num']) && $_POST['num']==$i)  
2365 - echo "<option value='".$i."' selected='selected'>".$i."</option>";  
2366 - else  
2367 - echo "<option value='".$i."'>".$i."</option>";  
2368 - }  
2369 - echo "</select>";  
2370 - echo " rows ";  
2371 - echo "<input type='submit' value='Go' class='btn'/>";  
2372 - echo "</form>";  
2373 - echo "<br/>";  
2374 - $query = "PRAGMA table_info('".$_GET['table']."')";  
2375 - $result = $db->selectArray($query);  
2376 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=row_create&confirm=1' method='post'>";  
2377 - if(isset($_POST['num']))  
2378 - $num = $_POST['num'];  
2379 - else  
2380 - $num = 1;  
2381 - echo "<input type='hidden' name='numRows' value='".$num."'/>";  
2382 - for($j=0; $j<$num; $j++)  
2383 - {  
2384 - if($j>0)  
2385 - echo "<input type='checkbox' value='ignore' name='".$j.":ignore' id='".$j."_ignore' checked='checked'/> Ignore<br/>";  
2386 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2387 - echo "<tr>";  
2388 - echo "<td class='tdheader'>Field</td>";  
2389 - echo "<td class='tdheader'>Type</td>";  
2390 - echo "<td class='tdheader'>Function</td>";  
2391 - echo "<td class='tdheader'>Value</td>";  
2392 - echo "</tr>";  
2393 -  
2394 - for($i=0; $i<sizeof($result); $i++)  
2395 - {  
2396 - $field = $result[$i][1];  
2397 - if($j==0)  
2398 - $fieldStr .= ":".$field;  
2399 - $type = $result[$i][2];  
2400 - $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>";  
2401 - $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>";  
2402 - echo "<tr>";  
2403 - echo $tdWithClassLeft;  
2404 - echo $field;  
2405 - echo "</td>";  
2406 - echo $tdWithClassLeft;  
2407 - echo $type;  
2408 - echo "</td>";  
2409 - echo $tdWithClassLeft;  
2410 - echo "<select name='function_".$j."_".$field."'>";  
2411 - echo "<option value=''></option>";  
2412 - $functions = unserialize(FUNCTIONS);  
2413 - for($z=0; $z<sizeof($functions); $z++)  
2414 - {  
2415 - echo "<option value='".$functions[$z]."'>".$functions[$z]."</option>";  
2416 - }  
2417 - echo "</select>";  
2418 - echo "</td>";  
2419 - echo $tdWithClassLeft;  
2420 - if($type=="INTEGER" || $type=="REAL" || $type=="NULL")  
2421 - echo "<input type='text' name='".$j.":".$field."' onblur='changeIgnore(this, \"".$j."_ignore\")'/>";  
2422 - else  
2423 - echo "<textarea name='".$j.":".$field."' wrap='hard' rows='1' cols='60' onblur='changeIgnore(this, \"".$j."_ignore\")'></textarea>";  
2424 - echo "</td>";  
2425 - echo "</tr>";  
2426 - }  
2427 - echo "<tr>";  
2428 - echo "<td class='tdheader' style='text-align:right;' colspan='4'>";  
2429 - echo "<input type='submit' value='Insert' class='btn'/>";  
2430 - echo "</td>";  
2431 - echo "</tr>";  
2432 - echo "</table><br/>";  
2433 - }  
2434 - $fieldStr = substr($fieldStr, 1);  
2435 - echo "<input type='hidden' name='fields' value='".$fieldStr."'/>";  
2436 - echo "</form>";  
2437 - break;  
2438 - /////////////////////////////////////////////// edit or delete row  
2439 - case "row_editordelete":  
2440 - if(isset($_POST['check']))  
2441 - $pks = $_POST['check'];  
2442 - else if(isset($_GET['pk']))  
2443 - $pks = array($_GET['pk']);  
2444 - $str = $pks[0];  
2445 - $pkVal = $pks[0];  
2446 - for($i=1; $i<sizeof($pks); $i++)  
2447 - {  
2448 - $str .= ", ".$pks[$i];  
2449 - $pkVal .= ":".$pks[$i];  
2450 - }  
2451 - if($str=="") //nothing was selected so show an error  
2452 - {  
2453 - echo "<div class='confirm'>";  
2454 - echo "Error: You did not select anything.";  
2455 - echo "</div>";  
2456 - echo "<br/><br/><a href='".PAGE."?table=".$_GET['table']."&action=row_view'>Return</a>";  
2457 - }  
2458 - else  
2459 - {  
2460 - if((isset($_POST['type']) && $_POST['type']=="edit") || (isset($_GET['type']) && $_GET['type']=="edit")) //edit  
2461 - {  
2462 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=row_edit&confirm=1&pk=".$pkVal."' method='post'>";  
2463 - $query = "PRAGMA table_info('".$_GET['table']."')";  
2464 - $result = $db->selectArray($query);  
2465 -  
2466 - //build the POST array of fields  
2467 - $fieldStr = $result[0][1];  
2468 - for($j=1; $j<sizeof($result); $j++)  
2469 - $fieldStr .= ":".$result[$j][1];  
2470 -  
2471 - echo "<input type='hidden' name='fieldArray' value='".$fieldStr."'/>";  
2472 -  
2473 - for($j=0; $j<sizeof($pks); $j++)  
2474 - {  
2475 - $query = "SELECT * FROM ".$_GET['table']." WHERE ROWID = ".$pks[$j];  
2476 - $result1 = $db->select($query);  
2477 -  
2478 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2479 - echo "<tr>";  
2480 - echo "<td class='tdheader'>Field</td>";  
2481 - echo "<td class='tdheader'>Type</td>";  
2482 - echo "<td class='tdheader'>Function</td>";  
2483 - echo "<td class='tdheader'>Value</td>";  
2484 - echo "</tr>";  
2485 -  
2486 - for($i=0; $i<sizeof($result); $i++)  
2487 - {  
2488 - $field = $result[$i][1];  
2489 - $type = $result[$i][2];  
2490 - $value = $result1[$i];  
2491 - $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>";  
2492 - $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>";  
2493 - echo "<tr>";  
2494 - echo $tdWithClass;  
2495 - echo $field;  
2496 - echo "</td>";  
2497 - echo $tdWithClass;  
2498 - echo $type;  
2499 - echo "</td>";  
2500 - echo $tdWithClassLeft;  
2501 - echo "<select name='function_".$pks[$j]."_".$field."'>";  
2502 - echo "<option value=''></option>";  
2503 - $functions = unserialize(FUNCTIONS);  
2504 - for($z=0; $z<sizeof($functions); $z++)  
2505 - {  
2506 - echo "<option value='".$functions[$z]."'>".$functions[$z]."</option>";  
2507 - }  
2508 - echo "</select>";  
2509 - echo "</td>";  
2510 - echo $tdWithClassLeft;  
2511 - if($type=="INTEGER" || $type=="REAL" || $type=="NULL")  
2512 - echo "<input type='text' name='".$pks[$j].":".$field."' value='".$db->formatString($value)."'/>";  
2513 - else  
2514 - echo "<textarea name='".$pks[$j].":".$field."' wrap='hard' rows='1' cols='60'>".$db->formatString($value)."</textarea>";  
2515 - echo "</td>";  
2516 - echo "</tr>";  
2517 - }  
2518 - echo "<tr>";  
2519 - echo "<td class='tdheader' style='text-align:right;' colspan='4'>";  
2520 - echo "<input type='submit' value='Save Changes' class='btn'/> ";  
2521 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=row_view'>Cancel</a>";  
2522 - echo "</td>";  
2523 - echo "</tr>";  
2524 - echo "</table>";  
2525 - echo "<br/>";  
2526 - }  
2527 - echo "</form>";  
2528 - }  
2529 - else //delete  
2530 - {  
2531 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=row_delete&confirm=1&pk=".$pkVal."' method='post'>";  
2532 - echo "<div class='confirm'>";  
2533 - echo "Are you sure you want to delete row(s) ".$str." from table '".$_GET['table']."'?<br/><br/>";  
2534 - echo "<input type='submit' value='Confirm' class='btn'/> ";  
2535 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=row_view'>Cancel</a>";  
2536 - echo "</div>";  
2537 - }  
2538 - }  
2539 - break;  
2540 - //column actions  
2541 - /////////////////////////////////////////////// view column  
2542 - case "column_view":  
2543 - $query = "PRAGMA table_info('".$_GET['table']."')";  
2544 - $result = $db->selectArray($query);  
2545 -  
2546 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=column_delete' method='post' name='checkForm'>";  
2547 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2548 - echo "<tr>";  
2549 - echo "<td colspan='2'>";  
2550 - echo "</td>";  
2551 - echo "<td class='tdheader'>Column #</td>";  
2552 - echo "<td class='tdheader'>Field</td>";  
2553 - echo "<td class='tdheader'>Type</td>";  
2554 - echo "<td class='tdheader'>Not Null</td>";  
2555 - echo "<td class='tdheader'>Default Value</td>";  
2556 - echo "<td class='tdheader'>Primary Key</td>";  
2557 - echo "</tr>";  
2558 -  
2559 - for($i=0; $i<sizeof($result); $i++)  
2560 - {  
2561 - $colVal = $result[$i][0];  
2562 - $fieldVal = $result[$i][1];  
2563 - $typeVal = $result[$i][2];  
2564 - $notnullVal = $result[$i][3];  
2565 - $defaultVal = $result[$i][4];  
2566 - $primarykeyVal = $result[$i][5];  
2567 -  
2568 - if(intval($notnullVal)!=0)  
2569 - $notnullVal = "yes";  
2570 - else  
2571 - $notnullVal = "no";  
2572 - if(intval($primarykeyVal)!=0)  
2573 - $primarykeyVal = "yes";  
2574 - else  
2575 - $primarykeyVal = "no";  
2576 -  
2577 - $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>";  
2578 - $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>";  
2579 - echo "<tr>";  
2580 - echo $tdWithClass;  
2581 - echo "<input type='checkbox' name='check[]' value='".$fieldVal."' id='check_".$i."'/>";  
2582 - echo "</td>";  
2583 - echo $tdWithClass;  
2584 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=column_delete&pk=".$fieldVal."' style='color:red;'>delete</a>";  
2585 - echo "</td>";  
2586 - echo $tdWithClass;  
2587 - echo $colVal;  
2588 - echo "</td>";  
2589 - echo $tdWithClassLeft;  
2590 - echo $fieldVal;  
2591 - echo "</td>";  
2592 - echo $tdWithClassLeft;  
2593 - echo $typeVal;  
2594 - echo "</td>";  
2595 - echo $tdWithClassLeft;  
2596 - echo $notnullVal;  
2597 - echo "</td>";  
2598 - echo $tdWithClassLeft;  
2599 - echo $defaultVal;  
2600 - echo "</td>";  
2601 - echo $tdWithClassLeft;  
2602 - echo $primarykeyVal;  
2603 - echo "</td>";  
2604 - echo "</tr>";  
2605 - }  
2606 -  
2607 - echo "</table>";  
2608 -  
2609 - echo "<a onclick='checkAll()'>Check All</a> / <a onclick='uncheckAll()'>Uncheck All</a> <i>With selected:</i> ";  
2610 - echo "<select name='massType'>";  
2611 - //echo "<option value='edit'>Edit</option>";  
2612 - echo "<option value='delete'>Delete</option>";  
2613 - echo "</select> ";  
2614 - echo "<input type='hidden' name='structureDel' value='true'/>";  
2615 - echo "<input type='submit' value='Go' name='massGo' class='btn'/>";  
2616 - echo "</form>";  
2617 -  
2618 - echo "<br/>";  
2619 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=column_create' method='post'>";  
2620 - echo "<input type='hidden' name='tablename' value='".$_GET['table']."'/>";  
2621 - echo "Add <input type='text' name='tablefields' style='width:30px;' value='1'/> field(s) at end of table <input type='submit' value='Go' name='addfields' class='btn'/>";  
2622 - echo "</form>";  
2623 - echo "<br/><hr/><br/>";  
2624 - //$query = "SELECT * FROM sqlite_master WHERE type='index' AND tbl_name='".$_GET['table']."'";  
2625 - $query = "PRAGMA index_list(".$_GET['table'].")";  
2626 - $result = $db->selectArray($query);  
2627 - if(sizeof($result)>0)  
2628 - {  
2629 - echo "<h2>Indexes:</h2>";  
2630 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2631 - echo "<tr>";  
2632 - echo "<td colspan='1'>";  
2633 - echo "</td>";  
2634 - echo "<td class='tdheader'>Name</td>";  
2635 - echo "<td class='tdheader'>Unique</td>";  
2636 - echo "<td class='tdheader'>Seq. No.</td>";  
2637 - echo "<td class='tdheader'>Column #</td>";  
2638 - echo "<td class='tdheader'>Field</td>";  
2639 - echo "</tr>";  
2640 - for($i=0; $i<sizeof($result); $i++)  
2641 - {  
2642 - if($result[$i]['unique']==0)  
2643 - $unique = "no";  
2644 - else  
2645 - $unique = "yes";  
2646 -  
2647 - $query = "PRAGMA index_info(".$result[$i]['name'].")";  
2648 - $info = $db->selectArray($query);  
2649 - $span = sizeof($info);  
2650 -  
2651 - $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>";  
2652 - $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>";  
2653 - $tdWithClassSpan = "<td class='td".($i%2 ? "1" : "2")."' rowspan='".$span."'>";  
2654 - $tdWithClassLeftSpan = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;' rowspan='".$span."'>";  
2655 - echo "<tr>";  
2656 - echo $tdWithClassSpan;  
2657 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=index_delete&pk=".$result[$i]['name']."' style='color:red;'>delete</a>";  
2658 - echo "</td>";  
2659 - echo $tdWithClassLeftSpan;  
2660 - echo $result[$i]['name'];  
2661 - echo "</td>";  
2662 - echo $tdWithClassLeftSpan;  
2663 - echo $unique;  
2664 - echo "</td>";  
2665 - for($j=0; $j<$span; $j++)  
2666 - {  
2667 - if($j!=0)  
2668 - echo "<tr>";  
2669 - echo $tdWithClassLeft;  
2670 - echo $info[$j]['seqno'];  
2671 - echo "</td>";  
2672 - echo $tdWithClassLeft;  
2673 - echo $info[$j]['cid'];  
2674 - echo "</td>";  
2675 - echo $tdWithClassLeft;  
2676 - echo $info[$j]['name'];  
2677 - echo "</td>";  
2678 - echo "</tr>";  
2679 - }  
2680 - }  
2681 - echo "</table>";  
2682 - }  
2683 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=index_create' method='post'>";  
2684 - echo "<input type='hidden' name='tablename' value='".$_GET['table']."'/>";  
2685 - echo "<br/><div class='tdheader'>";  
2686 - echo "Create an index on <input type='text' name='numcolumns' style='width:30px;' value='1'/> columns <input type='submit' value='Go' name='addindex' class='btn'/>";  
2687 - echo "</div>";  
2688 - echo "</form>";  
2689 - break;  
2690 - /////////////////////////////////////////////// create column  
2691 - case "column_create":  
2692 - echo "<h2>Adding new field(s) to table '".$_POST['tablename']."'</h2>";  
2693 - if($_POST['tablefields']=="" || intval($_POST['tablefields'])<=0)  
2694 - echo "You must specify the number of table fields.";  
2695 - else if($_POST['tablename']=="")  
2696 - echo "You must specify a table name.";  
2697 - else  
2698 - {  
2699 - $num = intval($_POST['tablefields']);  
2700 - $name = $_POST['tablename'];  
2701 - echo "<form action='".PAGE."?table=".$_POST['tablename']."&action=column_create&confirm=1' method='post'>";  
2702 - echo "<input type='hidden' name='tablename' value='".$name."'/>";  
2703 - echo "<input type='hidden' name='rows' value='".$num."'/>";  
2704 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2705 - echo "<tr>";  
2706 - $headings = array("Field", "Type", "Primary Key", "Autoincrement", "Not NULL", "Default Value");  
2707 - for($k=0; $k<count($headings); $k++)  
2708 - echo "<td class='tdheader'>" . $headings[$k] . "</td>";  
2709 - echo "</tr>";  
2710 -  
2711 - for($i=0; $i<$num; $i++)  
2712 - {  
2713 - $tdWithClass = "<td class='td" . ($i%2 ? "1" : "2") . "'>";  
2714 - echo "<tr>";  
2715 - echo $tdWithClass;  
2716 - echo "<input type='text' name='".$i."_field' style='width:200px;'/>";  
2717 - echo "</td>";  
2718 - echo $tdWithClass;  
2719 - echo "<select name='".$i."_type' id='".$i."_type' onchange='toggleAutoincrement(".$i.");'>";  
2720 - $types = unserialize(DATATYPES);  
2721 - for($z=0; $z<sizeof($types); $z++)  
2722 - echo "<option value='".$types[$z]."'>".$types[$z]."</option>";  
2723 - echo "</select>";  
2724 - echo "</td>";  
2725 - echo $tdWithClass;  
2726 - echo "<input type='checkbox' name='".$i."_primarykey'/> Yes";  
2727 - echo "</td>";  
2728 - echo $tdWithClass;  
2729 - echo "<input type='checkbox' name='".$i."_autoincrement' id='".$i."_autoincrement'/> Yes";  
2730 - echo "</td>";  
2731 - echo $tdWithClass;  
2732 - echo "<input type='checkbox' name='".$i."_notnull'/> Yes";  
2733 - echo "</td>";  
2734 - echo $tdWithClass;  
2735 - echo "<input type='text' name='".$i."_defaultvalue' style='width:100px;'/>";  
2736 - echo "</td>";  
2737 - echo "</tr>";  
2738 - }  
2739 - echo "<tr>";  
2740 - echo "<td class='tdheader' style='text-align:right;' colspan='6'>";  
2741 - echo "<input type='submit' value='Add Field(s)' class='btn'/> ";  
2742 - echo "<a href='".PAGE."?table=".$_POST['tablename']."&action=column_view'>Cancel</a>";  
2743 - echo "</td>";  
2744 - echo "</tr>";  
2745 - echo "</table>";  
2746 - echo "</form>";  
2747 - }  
2748 - break;  
2749 - /////////////////////////////////////////////// delete column  
2750 - case "column_delete":  
2751 - if(isset($_POST['check']))  
2752 - $pks = $_POST['check'];  
2753 - else if(isset($_GET['pk']))  
2754 - $pks = array($_GET['pk']);  
2755 - $str = $pks[0];  
2756 - $pkVal = $pks[0];  
2757 - for($i=1; $i<sizeof($pks); $i++)  
2758 - {  
2759 - $str .= ", ".$pks[$i];  
2760 - $pkVal .= ":".$pks[$i];  
2761 - }  
2762 - if($str=="") //nothing was selected so show an error  
2763 - {  
2764 - echo "<div class='confirm'>";  
2765 - echo "Error: You did not select anything.";  
2766 - echo "</div>";  
2767 - echo "<br/><br/><a href='".PAGE."?table=".$_GET['table']."&action=column_view'>Return</a>";  
2768 - }  
2769 - else  
2770 - {  
2771 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=column_delete&confirm=1&pk=".$pkVal."' method='post'>";  
2772 - echo "<div class='confirm'>";  
2773 - echo "Are you sure you want to delete column(s) ".$str." from table '".$_GET['table']."'?<br/><br/>";  
2774 - echo "<input type='submit' value='Confirm' class='btn'/> ";  
2775 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=column_view'>Cancel</a>";  
2776 - echo "</div>";  
2777 - }  
2778 - break;  
2779 - /////////////////////////////////////////////// edit column  
2780 - case "column_edit":  
2781 - //this section will contain the code for editing a column  
2782 - break;  
2783 - /////////////////////////////////////////////// delete index  
2784 - case "index_delete":  
2785 - echo "<form action='".PAGE."?table=".$_GET['table']."&action=index_delete&pk=".$_GET['pk']."&confirm=1' method='post'>";  
2786 - echo "<div class='confirm'>";  
2787 - echo "Are you sure you want to delete index '".$_GET['pk']."'?<br/><br/>";  
2788 - echo "<input type='submit' value='Confirm' class='btn'/> ";  
2789 - echo "<a href='".PAGE."?table=".$_GET['table']."&action=column_view'>Cancel</a>";  
2790 - echo "</div>";  
2791 - echo "</form>";  
2792 - break;  
2793 - /////////////////////////////////////////////// create index  
2794 - case "index_create":  
2795 - echo "<h2>Creating new index on table '".$_POST['tablename']."'</h2>";  
2796 - if($_POST['numcolumns']=="" || intval($_POST['numcolumns'])<=0)  
2797 - echo "You must specify the number of table fields.";  
2798 - else if($_POST['tablename']=="")  
2799 - echo "You must specify a table name.";  
2800 - else  
2801 - {  
2802 - echo "<form action='".PAGE."?table=".$_POST['tablename']."&action=index_create&confirm=1' method='post'>";  
2803 - $num = intval($_POST['numcolumns']);  
2804 - $query = "PRAGMA table_info('".$_POST['tablename']."')";  
2805 - $result = $db->selectArray($query);  
2806 - echo "<fieldset><legend>Define index properties</legend>";  
2807 - echo "Index name: <input type='text' name='name'/><br/>";  
2808 - echo "Duplicate values: ";  
2809 - echo "<select name='duplicate'>";  
2810 - echo "<option value='yes'>Allowed</option>";  
2811 - echo "<option value='no'>Not Allowed</option>";  
2812 - echo "</select><br/>";  
2813 - echo "</fieldset>";  
2814 - echo "<br/>";  
2815 - echo "<fieldset><legend>Define index columns</legend>";  
2816 - for($i=0; $i<$num; $i++)  
2817 - {  
2818 - echo "<select name='".$i."_field'>";  
2819 - echo "<option value=''>--Ignore--</option>";  
2820 - for($j=0; $j<sizeof($result); $j++)  
2821 - echo "<option value='".$result[$j][1]."'>".$result[$j][1]."</option>";  
2822 - echo "</select> ";  
2823 - echo "<select name='".$i."_order'>";  
2824 - echo "<option value=''></option>";  
2825 - echo "<option value=' ASC'>Ascending</option>";  
2826 - echo "<option value=' DESC'>Descending</option>";  
2827 - echo "</select><br/>";  
2828 - }  
2829 - echo "</fieldset>";  
2830 - echo "<br/><br/>";  
2831 - echo "<input type='hidden' name='num' value='".$num."'/>";  
2832 - echo "<input type='submit' value='Create Index' class='btn'/> ";  
2833 - echo "<a href='".PAGE."?table=".$_POST['tablename']."&action=column_view'>Cancel</a>";  
2834 - echo "</form>";  
2835 - }  
2836 - break;  
2837 - }  
2838 - echo "</div>";  
2839 - }  
2840 - $view = "structure";  
2841 - if(!isset($_GET['table']) && !isset($_GET['confirm']) && (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action']!="table_create"))) //the absence of these fields means we are viewing the database homepage  
2842 - {  
2843 - if(isset($_GET['view']))  
2844 - $view = $_GET['view'];  
2845 - else  
2846 - $view = "structure";  
2847 -  
2848 - echo "<a href='".PAGE."?view=structure' ";  
2849 - if($view=="structure")  
2850 - echo "class='tab_pressed'";  
2851 - else  
2852 - echo "class='tab'";  
2853 - echo ">Structure</a>";  
2854 - echo "<a href='".PAGE."?view=sql' ";  
2855 - if($view=="sql")  
2856 - echo "class='tab_pressed'";  
2857 - else  
2858 - echo "class='tab'";  
2859 - echo ">SQL</a>";  
2860 - echo "<a href='".PAGE."?view=export' ";  
2861 - if($view=="export")  
2862 - echo "class='tab_pressed'";  
2863 - else  
2864 - echo "class='tab'";  
2865 - echo ">Export</a>";  
2866 - echo "<a href='".PAGE."?view=import' ";  
2867 - if($view=="import")  
2868 - echo "class='tab_pressed'";  
2869 - else  
2870 - echo "class='tab'";  
2871 - echo ">Import</a>";  
2872 - echo "<a href='".PAGE."?view=vacuum' ";  
2873 - if($view=="vacuum")  
2874 - echo "class='tab_pressed'";  
2875 - else  
2876 - echo "class='tab'";  
2877 - echo ">Vacuum</a>";  
2878 - echo "<div style='clear:both;'></div>";  
2879 - echo "<div id='main'>";  
2880 -  
2881 - if($view=="structure") //database structure - view of all the tables  
2882 - {  
2883 - $query = "SELECT sqlite_version() AS sqlite_version";  
2884 - $queryVersion = $db->select($query);  
2885 - $realVersion = $queryVersion['sqlite_version'];  
2886 -  
2887 - echo "<b>Database name</b>: ".$db->getName()."<br/>";  
2888 - echo "<b>Path to database</b>: ".$db->getPath()."<br/>";  
2889 - echo "<b>Size of database</b>: ".$db->getSize()."<br/>";  
2890 - echo "<b>Database last modified</b>: ".$db->getDate()."<br/>";  
2891 - echo "<b>SQLite version</b>: ".$realVersion."<br/>";  
2892 - echo "<b>SQLite extension</b>: ".$db->getType()."<br/>";  
2893 - echo "<b>PHP version</b>: ".phpversion()."<br/><br/>";  
2894 -  
2895 - $query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name";  
2896 - $result = $db->selectArray($query);  
2897 -  
2898 - $j = 0;  
2899 - for($i=0; $i<sizeof($result); $i++)  
2900 - if(substr($result[$i]['name'], 0, 7)!="sqlite_" && $result[$i]['name']!="")  
2901 - $j++;  
2902 -  
2903 - if($j==0)  
2904 - echo "No tables in database.<br/><br/>";  
2905 - else  
2906 - {  
2907 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
2908 - echo "<tr>";  
2909 - echo "<td class='tdheader'>Table</td>";  
2910 - echo "<td class='tdheader' colspan='10'>Action</td>";  
2911 - echo "<td class='tdheader'>Records</td>";  
2912 - echo "</tr>";  
2913 -  
2914 - $totalRecords = 0;  
2915 - for($i=0; $i<sizeof($result); $i++)  
2916 - {  
2917 - if(substr($result[$i]['name'], 0, 7)!="sqlite_" && $result[$i]['name']!="")  
2918 - {  
2919 - $records = $db->numRows($result[$i]['name']);  
2920 - $totalRecords += $records;  
2921 - $tdWithClass = "<td class='td".($i%2 ? "1" : "2")."'>";  
2922 - $tdWithClassLeft = "<td class='td".($i%2 ? "1" : "2")."' style='text-align:left;'>";  
2923 -  
2924 - echo "<tr>";  
2925 - echo $tdWithClassLeft;  
2926 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=row_view'>".$result[$i]['name']."</a><br/>";  
2927 - echo "</td>";  
2928 - echo $tdWithClass;  
2929 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=row_view'>Browse</a>";  
2930 - echo "</td>";  
2931 - echo $tdWithClass;  
2932 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=column_view'>Structure</a>";  
2933 - echo "</td>";  
2934 - echo $tdWithClass;  
2935 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=table_sql'>SQL</a>";  
2936 - echo "</td>";  
2937 - echo $tdWithClass;  
2938 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=table_search'>Search</a>";  
2939 - echo "</td>";  
2940 - echo $tdWithClass;  
2941 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=row_create'>Insert</a>";  
2942 - echo "</td>";  
2943 - echo $tdWithClass;  
2944 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=table_export'>Export</a>";  
2945 - echo "</td>";  
2946 - echo $tdWithClass;  
2947 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=table_import'>Import</a>";  
2948 - echo "</td>";  
2949 - echo $tdWithClass;  
2950 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=table_rename'>Rename</a>";  
2951 - echo "</td>";  
2952 - echo $tdWithClass;  
2953 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=table_empty' style='color:red;'>Empty</a>";  
2954 - echo "</td>";  
2955 - echo $tdWithClass;  
2956 - echo "<a href='".PAGE."?table=".$result[$i]['name']."&action=table_drop' style='color:red;'>Drop</a>";  
2957 - echo "</td>";  
2958 - echo $tdWithClass;  
2959 - echo $records;  
2960 - echo "</td>";  
2961 - echo "</tr>";  
2962 - }  
2963 - }  
2964 - echo "<tr>";  
2965 - echo "<td class='tdheader' colspan='11'>".sizeof($result)." table(s) total</td>";  
2966 - echo "<td class='tdheader' colspan='1' style='text-align:right;'>".$totalRecords."</td>";  
2967 - echo "</tr>";  
2968 - echo "</table>";  
2969 - echo "<br/>";  
2970 - }  
2971 - echo "<fieldset>";  
2972 - echo "<legend><b>Create new table on database '".$db->getName()."'</b></legend>";  
2973 - echo "<form action='".PAGE."?action=table_create' method='post'>";  
2974 - echo "Name: <input type='text' name='tablename' style='width:200px;'/> ";  
2975 - echo "Number of Fields: <input type='text' name='tablefields' style='width:90px;'/> ";  
2976 - echo "<input type='submit' name='createtable' value='Go' class='btn'/>";  
2977 - echo "</form>";  
2978 - echo "</fieldset>";  
2979 - }  
2980 - else if($view=="sql") //database SQL editor  
2981 - {  
2982 - $isSelect = false;  
2983 - if(isset($_POST['query']) && $_POST['query']!="")  
2984 - {  
2985 - $delimiter = $_POST['delimiter'];  
2986 - $queryStr = stripslashes($_POST['queryval']);  
2987 - $query = explode($delimiter, $queryStr); //explode the query string into individual queries based on the delimiter  
2988 -  
2989 - for($i=0; $i<sizeof($query); $i++) //iterate through the queries exploded by the delimiter  
2990 - {  
2991 - if(str_replace(" ", "", str_replace("\n", "", str_replace("\r", "", $query[$i])))!="") //make sure this query is not an empty string  
2992 - {  
2993 - $startTime = microtime(true);  
2994 - if(strpos(strtolower($query[$i]), "select ")!==false)  
2995 - {  
2996 - $isSelect = true;  
2997 - $result = $db->selectArray($query[$i], "assoc");  
2998 - }  
2999 - else  
3000 - {  
3001 - $isSelect = false;  
3002 - $result = $db->query($query[$i]);  
3003 - }  
3004 - $endTime = microtime(true);  
3005 - $time = round(($endTime - $startTime), 4);  
3006 -  
3007 - echo "<div class='confirm'>";  
3008 - echo "<b>";  
3009 - if($isSelect && $result)  
3010 - {  
3011 - if($isSelect)  
3012 - {  
3013 - $affected = sizeof($result);  
3014 - echo "Showing ".$affected." row(s). ";  
3015 - }  
3016 - else  
3017 - {  
3018 - $affected = $db->getAffectedRows();  
3019 - echo $affected." row(s) affected. ";  
3020 - }  
3021 - echo "(Query took ".$time." sec)</b><br/>";  
3022 - }  
3023 - else  
3024 - {  
3025 - echo "There is a problem with the syntax of your query ";  
3026 - echo "(Query was not executed)</b><br/>";  
3027 - }  
3028 - echo "<span style='font-size:11px;'>".$query[$i]."</span>";  
3029 - echo "</div><br/>";  
3030 - if($isSelect)  
3031 - {  
3032 - if(sizeof($result)>0)  
3033 - {  
3034 - $headers = array_keys($result[0]);  
3035 -  
3036 - echo "<table border='0' cellpadding='2' cellspacing='1' class='viewTable'>";  
3037 - echo "<tr>";  
3038 - for($j=0; $j<sizeof($headers); $j++)  
3039 - {  
3040 - echo "<td class='tdheader'>";  
3041 - echo $headers[$j];  
3042 - echo "</td>";  
3043 - }  
3044 - echo "</tr>";  
3045 - for($j=0; $j<sizeof($result); $j++)  
3046 - {  
3047 - $tdWithClass = "<td class='td".($j%2 ? "1" : "2")."'>";  
3048 - echo "<tr>";  
3049 - for($z=0; $z<sizeof($headers); $z++)  
3050 - {  
3051 - echo $tdWithClass;  
3052 - echo $result[$j][$headers[$z]];  
3053 - echo "</td>";  
3054 - }  
3055 - echo "</tr>";  
3056 - }  
3057 - echo "</table><br/><br/>";  
3058 - }  
3059 - }  
3060 - }  
3061 - }  
3062 - }  
3063 - else  
3064 - {  
3065 - $delimiter = ";";  
3066 - $queryStr = "";  
3067 - }  
3068 -  
3069 - echo "<fieldset>";  
3070 - echo "<legend><b>Run SQL query/queries on database '".$db->getName()."'</b></legend>";  
3071 - echo "<form action='".PAGE."?view=sql' method='post'>";  
3072 - echo "<textarea style='width:100%; height:300px;' name='queryval'>".$queryStr."</textarea>";  
3073 - echo "Delimiter <input type='text' name='delimiter' value='".$delimiter."' style='width:50px;'/> ";  
3074 - echo "<input type='submit' name='query' value='Go' class='btn'/>";  
3075 - echo "</form>";  
3076 - }  
3077 - else if($view=="vacuum")  
3078 - {  
3079 - if(isset($_POST['vacuum']))  
3080 - {  
3081 - $query = "VACUUM";  
3082 - $db->query($query);  
3083 - echo "<div class='confirm'>";  
3084 - echo "The database, '".$db->getName()."', has been VACUUMed.";  
3085 - echo "</div><br/>";  
3086 - }  
3087 - echo "<form method='post' action='".PAGE."?view=vacuum'>";  
3088 - echo "Large databases sometimes need to be VACUUMed to reduce their footprint on the server. Click the button below to VACUUM the database, '".$db->getName()."'.";  
3089 - echo "<br/><br/>";  
3090 - echo "<input type='submit' value='VACUUM' name='vacuum' class='btn'/>";  
3091 - echo "</form>";  
3092 - }  
3093 - else if($view=="export")  
3094 - {  
3095 - echo "<form method='post' action='".PAGE."?view=export'>";  
3096 - echo "<fieldset style='float:left; width:260px; margin-right:20px;'><legend><b>Export</b></legend>";  
3097 - echo "<select multiple='multiple' size='10' style='width:240px;' name='tables[]'>";  
3098 - $query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name";  
3099 - $result = $db->selectArray($query);  
3100 - for($i=0; $i<sizeof($result); $i++)  
3101 - {  
3102 - if(substr($result[$i]['name'], 0, 7)!="sqlite_" && $result[$i]['name']!="")  
3103 - echo "<option value='".$result[$i]['name']."' selected='selected'>".$result[$i]['name']."</option>";  
3104 - }  
3105 - echo "</select>";  
3106 - echo "<br/><br/>";  
3107 - echo "<input type='radio' name='export_type' checked='checked' value='sql'/> SQL";  
3108 - echo "</fieldset>";  
3109 - echo "<fieldset style='float:left;'><legend><b>Options</b></legend>";  
3110 - echo "<input type='checkbox' checked='checked' name='structure'/> Export with structure [<a onmouseover='tooltip.show(\"Creates the queries to add the tables and their columns\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
3111 - echo "<input type='checkbox' checked='checked' name='data'/> Export with data [<a onmouseover='tooltip.show(\"Creates the queries to insert the table rows\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
3112 - echo "<input type='checkbox' name='drop'/> Add DROP TABLE [<a onmouseover='tooltip.show(\"Creates the queries to remove the tables before potentially adding them so that errors do not occur if they already exist\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
3113 - echo "<input type='checkbox' checked='checked' name='transaction'/> Add TRANSACTION [<a onmouseover='tooltip.show(\"Performs queries within transactions so that if an error occurs, the table is not returned to a partially incomplete and unusable state\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
3114 - echo "<input type='checkbox' checked='checked' name='comments'/> Comments [<a onmouseover='tooltip.show(\"Adds comments to the file to explain what is happening in each part of it\");' onmouseout='tooltip.hide();'>?</a>]<br/>";  
3115 - echo "</fieldset>";  
3116 - echo "<div style='clear:both;'></div>";  
3117 - echo "<br/><br/>";  
3118 - echo "<fieldset style='float:left;'><legend><b>Save As</b></legend>";  
3119 - echo "<input type='hidden' name='database_num' value='".$_SESSION[COOKIENAME.'currentDB']."'/>";  
3120 - echo "<input type='text' name='filename' value='".$db->getPath().".".date("n-j-y").".dump' style='width:400px;'/> <input type='submit' name='export' value='Export' class='btn'/>";  
3121 - echo "</fieldset>";  
3122 - echo "</form>";  
3123 - }  
3124 - else if($view=="import")  
3125 - {  
3126 - if(isset($_POST['import']))  
3127 - {  
3128 - echo "<div class='confirm'>";  
3129 - echo "Import was successful.";  
3130 - echo "</div><br/>";  
3131 - }  
3132 - echo "<form method='post' action='".PAGE."?view=import' enctype='multipart/form-data'>";  
3133 - echo "<fieldset><legend><b>File to import</b></legend>";  
3134 - echo "<input type='radio' name='export_type' checked='checked' value='sql'/> SQL";  
3135 - echo "<br/><br/>";  
3136 - echo "<input type='file' value='Choose File' name='file' style='background-color:transparent; border-style:none;'/> <input type='submit' value='Import' name='import' class='btn'/>";  
3137 - echo "</fieldset>";  
3138 - }  
3139 -  
3140 - echo "</div>";  
3141 - }  
3142 -  
3143 - echo "<br/>";  
3144 - $endTimeTot = microtime(true); //get the current time at this point in the execution  
3145 - $timeTot = round(($endTimeTot - $startTimeTot), 4); //calculate the total time for page load  
3146 - echo "<span style='font-size:11px;'>Powered by <a href='http://code.google.com/p/phpliteadmin/' target='_blank' style='font-size:11px;'>".PROJECT."</a> | Page generated in ".$timeTot." seconds.</span>";  
3147 - echo "</div>";  
3148 - echo "</div>";  
3149 - $db->close(); //close the database  
3150 -}  
3151 -echo "</body>";  
3152 -echo "</html>";  
3153 -  
3154 -?>  
3155 \ No newline at end of file 0 \ No newline at end of file
pacotes/phpliteadmin/senha.php
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -<?php  
2 -$password = $i3geomaster[0]["senha"];  
3 -?>  
4 \ No newline at end of file 0 \ No newline at end of file