<?php
/**
phpSQLiteAdmin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
phpSQLiteAdmin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with phpSQLiteAdmin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright 2004 Richard Heyes
Copyright 2006-2009 Marius Stanciu <marius.stanciu@code-purity.com>
*/
/**
* Enter description here...
*
* @package phpSQLiteAdmin
* @author Marius Stanciu Sergiu <marius.stanciu@code-purity.com>
* @copyright Copyright (c) 2006-2009, Code Purity www.code-purity.com
* @link http://blog.code-purity.com/pages/phpsqliteadmin
* @since Version 0.1.0
*/
include('config/config.php');
include($config['base_dir'].'include/initialize.php');
$do = intval($_GET['do']);
switch ($do)
{
case 9:
if (empty($_SESSION['database']['name']))
{
common::redirect('index.php?do=9', common::lang('No database name given!'));
}
$DB = &database::singleton($_SESSION['database']['params']);
$tables = sqlite::get_table_list();
$totalRecords = 0;
$views = sqlite::get_view_list();
$filemtime = filemtime($_SESSION['database']['path']);
$xDaysAgo = number_format((time() - $filemtime)/86400, 1).common::lang(' days ago');
$template = 'database.tpl';
break;
case 1:
if (empty($_SESSION['database']['name']))
{
common::redirect('index.php?do=9', common::lang('No database name given!'));
}
if (isset($_GET['table']))
{
$tableName = htmlspecialchars($_GET['table']);
}
else if (isset($_POST['table']))
{
$tableName = htmlspecialchars($_POST['table']);
}
$DB = &database::singleton($_SESSION['database']['params']);
if (!empty($_POST['sql']))
{
$sql = $origSql = trim($_POST['sql']);
$identifier = '([a-z][a-z0-9_]*|\[[a-z][a-z0-9_]*\])';
if (!preg_match('/\s+FROM\s+[a-z]/i', $sql) OR preg_match('/(NATURAL)?\s*(LEFT|RIGHT|FULL)?\s*(OUTER|INNER|CROSS)?\s*JOIN/i', $sql) OR preg_match("/\s+FROM\s+$identifier\s*,/i", $sql) OR preg_match('/^SELECT.+\(.+FROM/Ui', $sql))
{
$showEditDelete = false;
}
else
{
preg_match("/\s+FROM\s+$identifier\s*/i", $sql, $matches);
$tablename = $matches[1];
$showEditDelete = ($tablename != 'sqlite_master' ? true : false);
}
if (!preg_match('/LIMIT\s+([0-9]+)(\s+OFFSET\s+([0-9])+)?$/i', $sql, $matches) AND preg_match('/^SELECT/i', $sql))
{
$sql .= ' LIMIT 30 OFFSET 0';
$limitNumber = 30;
$offsetNumber = 0;
}
else
{
$limitNumber = @$matches[1];
$offsetNumber = @$matches[3];
}
if (preg_match('/^select /i', $sql) AND $showEditDelete)
{
$sql = preg_replace('/^(select) /i', '$1 _ROWID_, ', $sql);
}
$result = $DB->query($sql);
$querySuccessful = is_object($result) OR $result;
$queryHasResults = is_object($result) AND $result->num_rows() > 0;
if ($queryHasResults)
{
$resultsTable = array();
$headers = array();
while ($row = $result->fetch_row())
{
$resultsRow = array();
if (empty($headers))
{
$headers = array_slice(array_keys($row), $showEditDelete ? 1 : 0);
}
foreach ($row as $k => $v)
{
if ($k == '_ROWID_' AND empty($resultsRow) AND $showEditDelete)
{
$resultsRow[] = sprintf('<nobr><a href="%s" title="%s"><span class="ui-icon ui-icon-document"></span></a> <a href="%s" title="%s" onclick="return confirm(\'%s\')"><span class="ui-icon ui-icon-trash"></a></nobr>', common::url("index.php?do=3&action=edit&table=$tablename&rowid=$v&redirect=".rawurlencode(common::url())), common::lang('Edit'), common::url("index.php?do=3&action=delete&table=$tablename&rowid=$v&redirect=".rawurlencode(common::url())), common::lang('Delete'), common::lang('Are you sure you want to delete this row?'));
}
else
{
$resultsRow[] = $v;
}
}
$resultsTable[] = $resultsRow;
}
}
}
$origSql = "SELECT * FROM ".htmlspecialchars($tableName);
$template = 'query.tpl';
break;
case 2:
if (empty($_SESSION['database']['name']))
{
common::redirect('index.php?do=9', common::lang('No database name given!'));
}
if (empty($_GET['table']))
{
common::redirect('index.php?do=9', common::lang('No table given!'));
}
else
{
$tableName = htmlspecialchars($_GET['table']);
}
$DB = &database::singleton($_SESSION['database']['params']);
switch (@$_GET['action'])
{
case 'addindex':
if (!empty($_GET['column']) AND !empty($_GET['index']))
{
$index = htmlspecialchars($_GET['index']);
$column = htmlspecialchars($_GET['column']);
$unique = !empty($_GET['unique']) ? 'UNIQUE' : '';
$result = $DB->query("CREATE $unique INDEX $index ON $tableName ($column)");
$message = $result ? null : common::lang('Failed to create index, SQLite said: ').$DB->get_last_error();
common::redirect("index.php?do=2&table=$tableName", $message);
}
else common::redirect("index.php?do=2&table=$tableName", common::lang('Column or index name missing - cannot create index'));
break;
case 'dropindex':
if (!empty($_GET['index']))
{
$index = htmlspecialchars($_GET['index']);
$result = $DB->query("DROP INDEX $index");
$message = $result ? null : common::lang('Failed to create index, SQLite said: ').$DB->get_last_error();
common::redirect("index.php?do=2&table=$tableName", $message);
}
else
{
common::redirect("index.php?do=2table=$tableName", common::lang('Index name missing - cannot drop index'));
}
break;
case 'empty':
$result = $DB->query("DELETE FROM $tableName");
$message = $result ? sprintf(common::lang('Table %s was emptied'), $tableName) : common::lang('Failed to empty table!');
$redirect = !empty($_GET['redirect']) ? htmlspecialchars($_GET['redirect']) : 'index.php?do=9';
common::redirect($redirect, $message);
break;
case 'drop':
$result = $DB->query("DROP TABLE $tableName");
$message = $result ? sprintf(common::lang('Table %s was dropped'), $tableName) : 'Failed to empty table!';
$redirect = !empty($_GET['redirect']) ? htmlspecialchars($_GET['redirect']) : 'index.php?do=9';
common::redirect($redirect, $message);
break;
default:
$structure = sqlite::get_table_structure($tableName);
$rowCount = count($structure);
$indexes = sqlite::get_index_list($tableName, true);
break;
}
$template = 'table.tpl';
break;
case 3:
if (empty($_SESSION['database']['name']))
{
common::redirect('index.php?do=9', common::lang('No database name given!'));
}
if (empty($_GET['table']))
{
common::redirect('index.php?do=9', common::lang('No table given!'));
}
else
{
$tableName = htmlspecialchars($_GET['table']);
}
if ($_GET['action'] != 'insert')
{
if (empty($_GET['rowid']))
{
common::redirect("index.php?do=2&table=$tableName", common::lang('No row ID given!'));
}
else
{
$rowID = htmlspecialchars($_GET['rowid']);
}
}
switch ($_GET['action'])
{
case 'delete':
$result = sqlite::delete_row($rowID, $tableName);
common::redirect(htmlspecialchars($_GET['redirect']), $result ? common::lang('Row deleted') : common::lang('Failed to delete row!'));
break;
case 'edit':
$isUpdate = true;
$isInsert = false;
$DB = &database::singleton($_SESSION['database']['params']);
sqlite::get_user_functions();
if (!empty($_POST))
没有合适的资源?快使用搜索试试~ 我知道了~
PHP实例开发源码-phpSQLiteAdmin 2 在线数据库管理php程序.zip
共84个文件
png:21个
gif:15个
tpl:14个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 73 浏览量
2022-10-15
15:39:22
上传
评论
收藏 168KB ZIP 举报
温馨提示
PHP实例开发源码—phpSQLiteAdmin 2 在线数据库管理php程序.zip PHP实例开发源码—phpSQLiteAdmin 2 在线数据库管理php程序.zip PHP实例开发源码—phpSQLiteAdmin 2 在线数据库管理php程序.zip
资源推荐
资源详情
资源评论
收起资源包目录
PHP实例开发源码—phpSQLiteAdmin 2 在线数据库管理php程序.zip (84个子文件)
132699369015088330
index.php 22KB
config
auth.db 3KB
.htaccess 15B
config.php 2KB
index.html 0B
images
ui-icons_fcdd4a_256x240.png 5KB
view.gif 369B
ui-bg_flat_0_e6b900_40x100.png 181B
table.gif 365B
ui-bg_inset-hard_100_eeeeee_1x100.png 91B
ui-icons_0a82eb_256x240.png 4KB
folder.gif 249B
checked.png 781B
treeview-default.gif 1KB
unchecked.png 715B
button_home.png 920B
ui-icons_5fa5e3_256x240.png 4KB
treeview-default-line.gif 2KB
root_closed.gif 258B
index.html 0B
ui-bg_diagonals-thick_22_1484e6_40x40.png 259B
action.gif 251B
minus.gif 837B
ui-bg_highlight-soft_100_f9f9f9_1x100.png 88B
ui-bg_flat_0_e69700_40x100.png 181B
ui-bg_diagonals-thick_26_2293f7_40x40.png 259B
file.gif 110B
arrow.up.gif 841B
logo_left.png 3KB
ui-bg_diagonals-small_25_c5ddfc_40x40.png 157B
plus.gif 841B
database.gif 243B
ui-bg_diagonals-thick_20_e69700_40x40.png 257B
ui-icons_ffffff_256x240.png 4KB
root.gif 263B
folder-closed.gif 260B
button_loggoff.png 1KB
arrow.down.gif 841B
button_doc.png 1KB
ui-icons_0b54d5_256x240.png 4KB
button_help.png 1KB
favicon.ico 1KB
ui-bg_diagonals-thick_20_666666_40x40.png 251B
docs
CREDITS 164B
index.html 0B
LICENSE 15KB
lang
lang.ro.php 8KB
index.html 0B
include
css
index.html 0B
screen.css 4KB
treeview.css 2KB
jqueryui.css 27KB
functions
index.html 0B
sqlite_user_sample.php 976B
auth
config.php 2KB
index.html 0B
sqlite.php 2KB
authentication.php 3KB
index.html 0B
js
jquery.js 56KB
application.js 4KB
jqueryui.js 188KB
index.html 0B
treeview.js 5KB
initialize.php 2KB
common.php 14KB
database.php 19KB
themes
index.html 0B
default
table.tpl 3KB
export.tpl 472B
master.tpl 2KB
left.tpl 3KB
login.tpl 2KB
dbquery.tpl 2KB
browse.tpl 1KB
index.html 0B
query.tpl 2KB
view.tpl 2KB
frameset.tpl 757B
database.tpl 5KB
right.tpl 2KB
builder.tpl 10KB
row.tpl 4KB
login.php 3KB
共 84 条
- 1
资源评论
易小侠
- 粉丝: 6487
- 资源: 9万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功