PK tF<OneSQLiteAdmin/PK r\<]AOneSQLiteAdmin/db_admin.dbSQLite format 3@  wAtableadmin_dbadmin_dbCREATE TABLE admin_db (id INTEGER, name VARCHAR(256), path VARCHAR(512), PRIMARY KEY (id)) O/Utest.db/var/www/html/php/oneSQLiteM/test.dbE1kimg_rank_db.sqlite/var/www/html../../common_db/img_rank_db.sqlite/Utest.db/var/www/html/php/oneSQLiteM/test.db7#]db_admin.db/var/www/html/php/oneSQLiteM/db_admin.dbPK n<:YYOneSQLiteAdmin/index.php EOF ,"top"); exit; //ログインページ表示 }else if($_GET["s"] == "login"){ echo buildHtml(getLoginP(),"login"); //index表示 }else if($_GET["s"] == "index"){ $me = $_SERVER["SCRIPT_NAME"]; $PHPversion = phpversion(); $SQLiteVersions = "non"; //PDOが存在かつsqliteのドライバがある場合 if(class_exists('PDO') && in_array('sqlite', PDO::getavailabledrivers())) { //メモリ内にデータベースを作成し、SQLiteのバージョンを取得 $memoryDB = new PDO('sqlite::memory:', '', ''); $query = "SELECT sqlite_version();"; $result = $memoryDB->query($query); $SQLiteVersion = $result->fetchColumn(); unset($memoryDB, $result,$query); } $head = << EOF; $body = <<OneSQLiteAdmin
PHP version {$PHPversion}
SQLite version {$SQLiteVersion}

EOF; echo buildHtml_s($body,"index",$head); exit; //menu表示 }else if($_GET["s"] == "menu"){ $me = $_SERVER["SCRIPT_NAME"]; $body = <<TOP|logout
EOF; $head = << EOF; echo buildHtml_s($body,"menu",$head); exit; //jsonの場合 }else if(@$_GET["s"]=="json"){ //dblistを取得の場合 if(@$_GET["p"]=="dblist"){ echo json_encode(getdbdata($config["db"])); exit; } //htmlの場合 }else if(@$_GET["s"]=="html"){ //dblistを取得の場合 if(@$_GET["p"]=="dblist"){ $dbdata = getdbdata($config["db"]); $body = '
    '; foreach($dbdata as $key => $value){ $db = $value["db"]; $body .= '
  • '.$db.'
  • '; } $body .= '
'; echo $body; exit; //tablelistを取得の場合 }elseif(@$_GET["p"]=="tbllist"){ $dbid = @$_GET["dbid"]; $tbl_dbh = new PDO('sqlite:'.$config["db"][$dbid],'', ''); $table_names = $tbl_dbh->prepare("select name from sqlite_master where type='table' order by name"); $table_names->execute(); $table_names = $table_names->fetchAll(PDO::FETCH_ASSOC); $body = ''; echo $body; exit; //table構造取得 }elseif(@$_GET["p"]=="tblstructure"){ $tblname = $_GET["tblname"]; $tbl_dbh = new PDO('sqlite:'.$config["db"][$_GET["dbid"]],'', ''); $table_infoes = $tbl_dbh->prepare("PRAGMA table_info('".$tblname."');"); $table_infoes->execute(); $table_infoes = $table_infoes->fetchAll(PDO::FETCH_ASSOC); $body = ""; $body .= << EOF; foreach($table_infoes[0] as $table_info_c=>$table_info_v){ $body .= ''; $body .= $table_info_c; $body .= ''; } $body .= ''; foreach($table_infoes as $table_info){ $body .= ''; foreach($table_info as $table_info_i){ $body .= ''; $body .= $table_info_i; $body .= ''; } $body .= ''; } $body .= ''; echo $body; exit; //tableデータ取得 }elseif(@$_GET["p"]=="tbldata"){ $tblname = $_GET["tblname"]; $tbl_dbh = new PDO('sqlite:'.$config["db"][$_GET["dbid"]],'', ''); //件数取得 $tbl_count = $tbl_dbh->prepare("SELECT count(*) as c FROM ".$tblname); $tbl_count->execute(); $tbl_count = $tbl_count->fetchAll(); $rows_count = $tbl_count[0]["c"]; if($rows_count>0){ //現在のページ設定 if(isset($_GET["i"])){$p = $_GET["i"]; }else{$p = 1;} //1ページに表示するリミット設定(オプション) if(isset($_GET["l"])){$limit = $_GET["l"];} if(empty($limit)){$limit = 5; }else{$limit = intval($limit);} //ソート関連 if(isset($_GET["sort"])){$sort = " ORDER BY ".$_GET["sort"]." ".$_GET["jun"]; }else{$sort = "";} //現在のページ $p = (ceil($rows_count / $limit) < $p)?ceil($rows_count / $limit):$p; $offset = ($p-1)*$limit; $table_infoes = $tbl_dbh->prepare("SELECT * FROM ".$tblname." {$sort} LIMIT {$offset} , {$limit} "); $table_infoes->execute(); $table_infoes = $table_infoes->fetchAll(PDO::FETCH_ASSOC); } $body = ""; $body .= getTableView($table_infoes,$limit); $body .= page_pager($p,$rows_count,$limit); echo $body; exit; }elseif(@$_GET["p"]=="sql"){ $dbid = $_GET["dbid"]; $body = <<
EOF; echo $body; exit; }elseif(@$_GET["p"]=="sqlexec"){ $dbid = $_GET["dbid"]; $sql = @$_POST["sql"]; $body =""; $err_msg = ""; $hidden_sql = ""; $TableView = ""; try { $tbl_dbh = new PDO('sqlite:'.$config["db"][$_GET["dbid"]],'', ''); $tbl_dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if(preg_match('/^select/i',ltrim($sql))){ $count_sql = preg_replace('/LIMIT *[0-9].*/i','',$sql); $count_sql = 'select count(*) as c from '.preg_replace('/^select.*from/i','',ltrim($count_sql)); $table_infoes = $tbl_dbh->query($count_sql); $table_infoes = $table_infoes->fetchAll(PDO::FETCH_ASSOC); $rows_count = $table_infoes[0]["c"]; if($rows_count>0){ //現在のページ設定 if(isset($_POST["i"])){$p = $_POST["i"]; }else{$p = 1;} //1ページに表示するリミット設定(オプション) if(isset($_GET["l"])){$limit = $_GET["l"];} if(empty($limit)){$limit = 5; }else{$limit = intval($limit);} //現在のページ $p = (ceil($rows_count / $limit) < $p)?ceil($rows_count / $limit):$p; $offset = ($p-1)*$limit; $sql = preg_replace('/;$/',"",rtrim($sql)); if(!preg_match('/LIMIT *[0-9]/i',$sql)){ $sql = $sql." LIMIT {$offset} , {$limit} "; } $table_infoes = $tbl_dbh->query($sql); $table_infoes = $table_infoes->fetchAll(PDO::FETCH_ASSOC); $hidden_sql = preg_replace('/LIMIT *[0-9].*/i','',$sql); $hidden_sql = ''; $TableView = getTableView($table_infoes,$limit); $TableView .= exec_page_pager($p,$rows_count,$limit); } }else{ $table_infoes = $tbl_dbh->exec($sql); } $tbl_dbh = null; } catch (PDOException $e) { $err_msg = $e->getMessage(); $body .= "
{$err_msg}
"; $tbl_dbh = null; } $body .= <<{$sql} EOF; if(!empty($TableView)){ $body .= $TableView.$hidden_sql; }else{ $body .= <<
EOF; } echo $body; exit; } //tblsの場合 }else if(@$_GET["s"] == "tbls"){ $dbid = $_GET["dbid"]; if(empty($config["db"][$dbid])){echo "err!
データベースが見つかりません。";exit;} $db_path = dirname(__FILE__)."/".$config["db"][$dbid]; $db_name = basename($db_path); $me = $_SERVER["SCRIPT_NAME"]; $head = << EOF; $body = <<{$db_name}

{$db_path}

EOF; echo buildHtml_s($body,"tbls",$head); exit; //tblの場合 }else if(@$_GET["s"] == "tbl"){ $tblname = $_GET["tblname"]; $dbid = $_GET["dbid"]; $me = $_SERVER["SCRIPT_NAME"]; $head = << EOF; $body = <<table info - ${tblname}


||
EOF; echo buildHtml_s($body,"tbl",$head); exit; } function getTableView($table_infoes,$viewlimit=5){ if(empty($table_infoes)){ return ""; } $body = ""; $body .= '表示件数:'; $body .= << EOF; foreach($table_infoes[0] as $table_info_c=>$table_info_v){ $body .= ''; $body .= $table_info_c; $body .= ''; } $body .= ''; foreach($table_infoes as $table_info){ $body .= ''; foreach($table_info as $table_info_i){ $body .= ''; $body .= $table_info_i; $body .= ''; } $body .= ''; } $body .= ''; return $body; } function page_pager($current_num,$countRe,$per_page=6){ // 現在のページ情報を取得 $VIEW_PAGE_MENU_WIDTH = 2; $PREV_MARK = "<"; $NEXT_MARK = ">"; $startMore=""; $endMore=""; $startPage=1; $endPage=0; $now_page =intval($current_num); $now_page =(empty($now_page))?1:$now_page; $now_page =(ceil($countRe / $per_page) < $now_page)?ceil($countRe / $per_page):$now_page; if($now_page=="") $now_page=1; $maxPage=ceil($countRe / $per_page); if( ($maxPage == 1) or ($maxPage < $now_page) ) return false; if($now_page > 1){ $startMore .= "".$PREV_MARK.""; if($now_page > $VIEW_PAGE_MENU_WIDTH + 1){ $startPage = $now_page - $VIEW_PAGE_MENU_WIDTH; $startMore .= "1..."; } }else{ $startPage = 1; } if($now_page < $maxPage){ if($now_page + $VIEW_PAGE_MENU_WIDTH < $maxPage){ $endPage = $now_page + $VIEW_PAGE_MENU_WIDTH; $endMore .= "...".$maxPage."\n"; }else{ $endPage = $maxPage; } $endMore .= "".$NEXT_MARK."\n"; }else{ $endPage = $maxPage; } $page_footer=""; for($i = $startPage ; $i <= $endPage ; $i++){ $page_footer.= " ".(($now_page==$i)?"$i\n":"$i\n"); } $page_footer = $startMore.$page_footer.$endMore; return $page_footer; } function exec_page_pager($current_num,$countRe,$per_page=6){ // 現在のページ情報を取得 $VIEW_PAGE_MENU_WIDTH = 2; $PREV_MARK = "<"; $NEXT_MARK = ">"; $startMore=""; $endMore=""; $startPage=1; $endPage=0; $now_page =intval($current_num); $now_page =(empty($now_page))?1:$now_page; $now_page =(ceil($countRe / $per_page) < $now_page)?ceil($countRe / $per_page):$now_page; if($now_page=="") $now_page=1; $maxPage=ceil($countRe / $per_page); if( ($maxPage == 1) or ($maxPage < $now_page) ) return false; if($now_page > 1){ $startMore .= "".$PREV_MARK.""; if($now_page > $VIEW_PAGE_MENU_WIDTH + 1){ $startPage = $now_page - $VIEW_PAGE_MENU_WIDTH; $startMore .= "1..."; } }else{ $startPage = 1; } if($now_page < $maxPage){ if($now_page + $VIEW_PAGE_MENU_WIDTH < $maxPage){ $endPage = $now_page + $VIEW_PAGE_MENU_WIDTH; $endMore .= "...".$maxPage."\n"; }else{ $endPage = $maxPage; } $endMore .= "".$NEXT_MARK."\n"; }else{ $endPage = $maxPage; } $page_footer=""; for($i = $startPage ; $i <= $endPage ; $i++){ $page_footer.= " ".(($now_page==$i)?"$i\n":"$i\n"); } $page_footer = $startMore.$page_footer.$endMore; return $page_footer; } function getdbdata($dbs){ for($i=0;$iprepare("select name from sqlite_master where type='table' order by name"); $table_names->execute(); $table_names = $table_names->fetchAll(PDO::FETCH_ASSOC); $j=0; $result[$i]["db"] = basename($dbs[$i]); for($j=0;$jログアウト

Logout...

Top

EOF; } function getericcss(){ return << // http://www.kawa.net/works/js/jkl/parsexml.html // ================================================================ // v0.01 2005/05/18 first release // v0.02 2005/05/20 Opera 8.0beta may be abailable but somtimes crashed // v0.03 2005/05/20 overrideMimeType( "text/xml" ); // v0.04 2005/05/21 class variables: REQUEST_TYPE, RESPONSE_TYPE // v0.05 2005/05/22 use Msxml2.DOMDocument.5.0 for GET method on IE6 // v0.06 2005/05/22 CDATA_SECTION_NODE // v0.07 2005/05/23 use Microsoft.XMLDOM for GET method on IE6 // v0.10 2005/10/11 new function: JKL.ParseXML.HTTP.responseText() // v0.11 2005/10/13 new sub class: JKL.ParseXML.Text, JSON and DOM. // v0.12 2005/10/14 new sub class: JKL.ParseXML.CSV and CSVmap. // v0.13 2005/10/28 bug fixed: TEXT_NODE regexp for white spaces // v0.14 2005/11/06 bug fixed: TEXT_NODE regexp at Safari // v0.15 2005/11/08 bug fixed: JKL.ParseXML.CSV.async() method // v0.16 2005/11/15 new sub class: LoadVars, and UTF-8 text on Safari // v0.18 2005/11/16 improve: UTF-8 text file on Safari // v0.19 2006/02/03 use XMLHTTPRequest instead of ActiveX on IE7,iCab // v0.20 2006/03/22 (skipped) // v0.21 2006/11/30 use ActiveX again on IE7 // v0.22 2007/01/04 JKL.ParseXML.JSON.parseResponse() updated // ================================================================ if ( typeof(JKL) == 'undefined' ) JKL = function() {}; // ================================================================ // class: JKL.ParseXML JKL.ParseXML = function ( url, query, method ) { // debug.print( "new JKL.ParseXML( '"+url+"', '"+query+"', '"+method+"' );" ); this.http = new JKL.ParseXML.HTTP( url, query, method, false ); return this; }; // ================================================================ // class variables JKL.ParseXML.VERSION = "0.22"; JKL.ParseXML.MIME_TYPE_XML = "text/xml"; JKL.ParseXML.MAP_NODETYPE = [ "", "ELEMENT_NODE", // 1 "ATTRIBUTE_NODE", // 2 "TEXT_NODE", // 3 "CDATA_SECTION_NODE", // 4 "ENTITY_REFERENCE_NODE", // 5 "ENTITY_NODE", // 6 "PROCESSING_INSTRUCTION_NODE", // 7 "COMMENT_NODE", // 8 "DOCUMENT_NODE", // 9 "DOCUMENT_TYPE_NODE", // 10 "DOCUMENT_FRAGMENT_NODE", // 11 "NOTATION_NODE" // 12 ]; // ================================================================ // define callback function (ajax) JKL.ParseXML.prototype.async = function ( func, args ) { this.callback_func = func; // callback function this.callback_arg = args; // first argument }; JKL.ParseXML.prototype.onerror = function ( func, args ) { this.onerror_func = func; // callback function }; // ================================================================ // method: parse() // return: parsed object // Download a file from remote server and parse it. JKL.ParseXML.prototype.parse = function () { if ( ! this.http ) return; // set onerror call back if ( this.onerror_func ) { this.http.onerror( this.onerror_func ); } if ( this.callback_func ) { // async mode var copy = this; var proc = function() { if ( ! copy.http ) return; var data = copy.parseResponse(); copy.callback_func( data, copy.callback_arg ); // call back }; this.http.async( proc ); } this.http.load(); if ( ! this.callback_func ) { // sync mode var data = this.parseResponse(); return data; } }; // ================================================================ // every child/children into array JKL.ParseXML.prototype.setOutputArrayAll = function () { this.setOutputArray( true ); } // a child into scalar, children into array JKL.ParseXML.prototype.setOutputArrayAuto = function () { this.setOutputArray( null ); } // every child/children into scalar (first sibiling only) JKL.ParseXML.prototype.setOutputArrayNever = function () { this.setOutputArray( false ); } // specified child/children into array, other child/children into scalar JKL.ParseXML.prototype.setOutputArrayElements = function ( list ) { this.setOutputArray( list ); } // specify how to treate child/children into scalar/array JKL.ParseXML.prototype.setOutputArray = function ( mode ) { if ( typeof(mode) == "string" ) { mode = [ mode ]; // string into array } if ( mode && typeof(mode) == "object" ) { if ( mode.length < 0 ) { mode = false; // false when array == [] } else { var hash = {}; for( var i=0; i" ); // COMMENT_NODE if ( elem.nodeType == 7 ) { return; } // TEXT_NODE CDATA_SECTION_NODE if ( elem.nodeType == 3 || elem.nodeType == 4 ) { // var bool = elem.nodeValue.match( /[^\\u0000-\\u0020]/ ); var bool = elem.nodeValue.match( /[^\\x00-\\x20]/ ); // for Safari if ( bool == null ) return; // ignore white spaces // debug.print( "TEXT_NODE: "+elem.nodeValue.length+ " "+bool ); return elem.nodeValue; } var retval; var cnt = {}; // parse attributes if ( elem.attributes && elem.attributes.length ) { retval = {}; for ( var i=0; i -1 ) { if ( text.charAt(nextquote+1) != '"' ) { break; // end of column } nextquote = text.indexOf( '"', nextquote+2 ); } if ( nextquote < 0 ) { // unclosed quote } else if ( text.charAt(nextquote+1) == "," ) { // end of column var quoted = text.substr( pos+1, nextquote-pos-1 ); quoted = quoted.replace(/""/g,'"'); line[line.length] = quoted; pos = nextquote+2; continue; } else if ( text.charAt(nextquote+1) == "\\n" || // end of line len==nextquote+1 ) { // end of file var quoted = text.substr( pos+1, nextquote-pos-1 ); quoted = quoted.replace(/""/g,'"'); line[line.length] = quoted; pos = nextquote+2; break; } else { // invalid column } } var nextcomma = text.indexOf( ",", pos ); var nextnline = text.indexOf( "\\n", pos ); if ( nextnline < 0 ) nextnline = len; if ( nextcomma > -1 && nextcomma < nextnline ) { line[line.length] = text.substr( pos, nextcomma-pos ); pos = nextcomma+1; } else { // end of line line[line.length] = text.substr( pos, nextnline-pos ); pos = nextnline+1; break; } } if ( line.length >= 0 ) { table[table.length] = line; // push line } } if ( table.length < 0 ) return; // null data return table; }; // ================================================================ // class: JKL.ParseXML.CSVmap JKL.ParseXML.CSVmap = function ( url, query, method ) { // debug.print( "new JKL.ParseXML.CSVmap( '"+url+"', '"+query+"', '"+method+"' );" ); this.http = new JKL.ParseXML.HTTP( url, query, method, true ); return this; }; JKL.ParseXML.CSVmap.prototype.parse = JKL.ParseXML.prototype.parse; JKL.ParseXML.CSVmap.prototype.async = JKL.ParseXML.prototype.async; JKL.ParseXML.CSVmap.prototype.onerror = JKL.ParseXML.prototype.onerror; JKL.ParseXML.CSVmap.prototype.parseCSV = JKL.ParseXML.CSV.prototype.parseCSV; JKL.ParseXML.CSVmap.prototype.parseResponse = function () { var text = this.http.responseText(); var source = this.parseCSV( text ); if ( ! source ) return; if ( source.length < 0 ) return; var title = source.shift(); // first line as title var data = []; for( var i=0; i 0 && this.req.status != 200 && // OK this.req.status != 206 && // Partial Content this.req.status != 304 ) { // Not Modified // debug.print( "status: "+this.req.status ); if ( this.onerror_func ) this.onerror_func( this.req.status ); return false; // failed } return true; // succeed } // ================================================================ // method: documentElement() // return: XML DOM in response body JKL.ParseXML.HTTP.prototype.documentElement = function() { // debug.print( "documentElement: "+this.req ); if ( ! this.req ) return; if ( this.req.responseXML ) { return this.req.responseXML.documentElement; // XMLHTTPRequest } else { return this.req.documentElement; // IXMLDOMDocument } } // ================================================================ // method: responseText() // return: text string in response body JKL.ParseXML.HTTP.prototype.responseText = function() { // debug.print( "responseText: "+this.req ); if ( ! this.req ) return; // Safari and Konqueror cannot understand the encoding of text files. if ( navigator.appVersion.match( "KHTML" ) ) { var esc = escape( this.req.responseText ); // debug.print( "escape: "+esc ); if ( ! esc.match("%u") && esc.match("%") ) { return decodeURIComponent(esc); } } return this.req.responseText; } // ================================================================ // http://msdn.microsoft.com/library/en-us/xmlsdk/html/d051f7c5-e882-42e8-a5b6-d1ce67af275c.asp // ================================================================ EOF; } function getLoginP(){ $me = $_SERVER["SCRIPT_NAME"]; return <<

ログイン

EOF; } /* *フレームの外側用 */ function buildHtml($body , $title="", $head=""){ if(empty($title)){ $title="OneSQLiteAdmin"; }else{ $title="OneSQLiteAdmin - ".$title; } $result = << ${title} {$head} EOF; $result .= $body; $result .= ""; return $result; } /* *フレームの内側用 */ function buildHtml_s($body , $title="", $head=""){ if(empty($title)){ $title="OneSQLiteAdmin"; }else{ $title="OneSQLiteAdmin - ".$title; } $result = << ${title} {$head} EOF; $result .= $body; $result .= ""; return $result; } PK tF<OneSQLiteAdmin/test/PK r\