OSDN Git Service

Add files via upload
[idb/iDB.git.git] / inc / admin / sqldumper / sqlite.php
index 471fd5d..81c5236 100644 (file)
@@ -8,10 +8,10 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     Revised BSD License for more details.
 
-    Copyright 2004-2009 iDB Support - http://idb.berlios.de/
-    Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
+    Copyright 2004-2019 iDB Support - https://idb.osdn.jp/support/category.php?act=view&id=1
+    Copyright 2004-2019 Game Maker 2k - https://idb.osdn.jp/support/category.php?act=view&id=2
 
-    $FileInfo: sqlite.php - Last Update: 12/15/2009 SVN 408 - Author: cooldude2k $
+    $FileInfo: sqlite.php - Last Update: 4/8/2022 SVN 951 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="sqlite.php"||$File3Name=="/sqlite.php") {
@@ -19,23 +19,68 @@ if ($File3Name=="sqlite.php"||$File3Name=="/sqlite.php") {
        exit(); }
 
 if($_SESSION['UserGroup']==$Settings['GuestGroup']||$GroupInfo['HasAdminCP']=="no") {
-redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
-if($Settings['sqltype']!="sqlite") {
-redirect("location",$basedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
+if($Settings['sqltype']!="sqlite"||$Settings['sqltype']!="sqlite3") {
+redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false));
 ob_clean(); header("Content-Type: text/plain; charset=".$Settings['charset']);
 gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die(); }
 if(!isset($_GET['outtype'])) { $_GET['outtype'] = "UTF-8"; }
 header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
 header("Cache-Control: private",false); 
 header("Content-Description: File Transfer");
-$fname = str_replace("_","", $Settings['sqltable']);
-header("Content-Disposition: attachment; filename=".$fname.".sql");
+if(!isset($_GET['comlevel'])) {
+       $_GET['comlevel'] = -1; }
+if(!is_numeric($_GET['comlevel'])) {
+       $_GET['comlevel'] = -1; }
+if($_GET['comlevel']>9||$_GET['comlevel']<-1) {
+       $_GET['comlevel'] = -1; }
+if(!isset($_GET['compress'])) {
+       $_GET['compress'] = "none"; }
+if($_GET['compress']=="gzip") {
+       $_GET['compress'] = "gzencode"; }
+if($_GET['compress']=="bzip"||
+       $_GET['compress']=="bzip2") {
+       $_GET['compress'] = "bzcompress"; }
+if($_GET['compress']!="none"&&
+       $_GET['compress']!="gzencode"&&
+       $_GET['compress']!="gzcompress"&&
+       $_GET['compress']!="gzdeflate"&&
+       $_GET['compress']!="bzcompress") {
+       $_GET['compress'] = "none"; }
+if(!extension_loaded("zlib")) {
+if($_GET['compress']=="gzencode"&&
+       $_GET['compress']=="gzcompress"&&
+       $_GET['compress']=="gzdeflate") {
+       $_GET['compress'] = "none"; } }
+if(!extension_loaded("bz2")) {
+if($_GET['compress']=="bzcompress") {
+       $_GET['compress'] = "none"; } }
+if($_GET['compress']=="bzcompress") {
+if($_GET['comlevel']>9||$_GET['comlevel']<0) {
+       $_GET['comlevel'] = 4; } }
+$fname = null;
+if(isset($Settings['sqldb'])&&$Settings['sqldb']!="") {
+$fname = str_replace("_","", $Settings['sqldb'])."_"; }
+if($_GET['compress']=="none") {
+$fname .= str_replace("_","", $Settings['sqltable']).".sql"; }
+if($_GET['compress']=="gzencode") {
+$fname .= str_replace("_","", $Settings['sqltable']).".sql.gz"; }
+if($_GET['compress']=="gzcompress") {
+$fname .= str_replace("_","", $Settings['sqltable']).".sql.gz"; }
+if($_GET['compress']=="gzdeflate") {
+$fname .= str_replace("_","", $Settings['sqltable']).".sql.gz"; }
+if($_GET['compress']=="bzcompress") {
+$fname .= str_replace("_","", $Settings['sqltable']).".sql.bz2"; }
+header("Content-Disposition: attachment; filename=".$fname);
 header("Content-Type: application/octet-stream");
 header("Content-Transfer-Encoding: binary");
-$SQLDumper = "SQL Dumper";
-function GetAllRows($table) { $rene_j = 0; $trowout = null;
+if(!isset($AltSQLDumper)||$AltSQLDumper===null) {
+       $SQLDumper = "SQL Dumper"; }
+if(isset($AltSQLDumper)&&$AltSQLDumper!==null) {
+       $SQLDumper = $AltSQLDumper; }
+function GetAllRows($table) { $rene_j = 0; $trowout = array();
 global $SQLStat;
 $tresult = sql_query("SELECT * FROM \"".$table."\"",$SQLStat);
 while ($trow = sql_fetch_assoc($tresult)) {
@@ -47,7 +92,7 @@ $TablePreFix = $Settings['sqltable'];
 function add_prefix($tarray) {
 global $TablePreFix;
 return $TablePreFix.$tarray; }
-$TableChCk = array("categories", "catpermissions", "events", "forums", "groups", "members", "messenger", "permissions", "posts", "restrictedwords", "sessions", "smileys", "topics", "wordfilter");
+$TableChCk = array("categories", "catpermissions", "events", "forums", "groups", "levels", "members", "mempermissions", "messenger", "permissions", "polls", "posts", "restrictedwords", "sessions", "smileys", "themes", "topics", "wordfilter");
 $TableChCk = array_map("add_prefix",$TableChCk);
 if(!isset($_GET['outtype'])||$_GET['outtype']=="UTF-8") {
 header("Content-Type: text/plain; charset=UTF-8"); }
@@ -82,25 +127,25 @@ $FullTable[$sli] .= "\n);\n";
 */
 ++$sli; }
 $TableNames = $TableChCk;
-$num = count($TableNames); $renee_s = 0;
-echo "-- ".$OrgName." ".$SQLDumper."\n";
-echo "-- version ".$VerInfo['iDB_Ver_SVN']."\n";
-echo "-- ".$iDBHome."support/\n";
-echo "--\n";
-echo "-- Generation Time: ".GMTimeGet('F d, Y \a\t h:i A',$_SESSION['UserTimeZone'],0,$_SESSION['UserDST'])."\n";
-echo "-- SQLite Server version: ".sql_server_info($SQLStat)."\n";
-echo "-- PHP Version: ".phpversion()."\n\n";
-echo "--\n";
-echo "-- Database: \"".$Settings['sqldb']."\"\n";
-echo "--\n\n";
-echo "-- --------------------------------------------------------\n\n";
-while ($renee_s < $num) { $tnum = $num - 1;
-$trow = GetAllRows($TableNames[$renee_s]);
+$num = count($TableNames); $melanie_p = 0;
+$sqldump = "-- ".$OrgName." ".$SQLDumper."\n";
+$sqldump .= "-- version ".$VerInfo['iDB_Ver_SVN']."\n";
+$sqldump .= "-- ".$iDBHome."support/\n";
+$sqldump .= "--\n";
+$sqldump .= "-- Generation Time: ".$usercurtime->format('F d, Y \a\t h:i A')."\n";
+$sqldump .= "-- SQLite Server version: ".sql_server_info($SQLStat)."\n";
+$sqldump .= "-- PHP Version: ".phpversion()."\n\n";
+$sqldump .= "--\n";
+$sqldump .= "-- Database: \"".$Settings['sqldb']."\"\n";
+$sqldump .= "--\n\n";
+$sqldump .= "-- --------------------------------------------------------\n\n";
+while ($melanie_p < $num) { $tnum = $num - 1;
+$trow = GetAllRows($TableNames[$melanie_p]);
 $numz = count($trow); $kazuki_p = 0;
-echo "--\n";
-echo "-- Table structure for table \"".$TableNames[$renee_s]."\"\n";
-echo "--\n\n";
-echo $FullTable[$renee_s]."\n";
+$sqldump .= "--\n";
+$sqldump .= "-- Table structure for table \"".$TableNames[$melanie_p]."\"\n";
+$sqldump .= "--\n\n";
+$sqldump .= $FullTable[$melanie_p]."\n";
 while ($kazuki_p < $numz) { $tnumz = $numz - 1;
 $srow = null; $srowvalue = null;
 $trownew = $trow[$kazuki_p];
@@ -112,7 +157,7 @@ $trowrvalue = sql_escape_string($trownew[$trowrname],$SQLStat);
 if($_GET['outtype']=="UTF-8"&&$Settings['charset']!="UTF-8") {
 $trowrvalue = utf8_encode($trowrvalue); }
 $trowrvalue = str_replace( array("\n", "\r"), array('\n', '\r'), $trowrvalue);
-if($il===0) { $srow = "INSERT INTO \"".$TableNames[$renee_s]."\" ("; }
+if($il===0) { $srow = "INSERT INTO \"".$TableNames[$melanie_p]."\" ("; }
 if($il<$tnums&&$il!=$tnums) { $srow .= "\"".$trowrname."\", "; }
 if($il==$tnums) { $srow .= "\"".$trowrname."\") VALUES"; }
 if($il===0) { $srowvalue = "("; }
@@ -123,20 +168,25 @@ if($kazuki_p<$tnumz) { $srowvalue .= ");"; }
 if($kazuki_p==$tnumz) { $srowvalue .= ");"; } }
 ++$il; }
 if($kazuki_p===0) {
-echo "--\n";
-echo "-- Dumping data for table \"".$TableNames[$renee_s]."\"\n";
-echo "--\n\n"; }
-echo $srow."\n";
-echo $srowvalue."\n";
-if($kazuki_p==$tnumz&&$renee_s<$tnum) {
-echo "\n-- --------------------------------------------------------\n"; }
+$sqldump .= "--\n";
+$sqldump .= "-- Dumping data for table \"".$TableNames[$melanie_p]."\"\n";
+$sqldump .= "--\n\n"; }
+$sqldump .= $srow."\n";
+$sqldump .= $srowvalue."\n";
+if($kazuki_p==$tnumz&&$melanie_p<$tnum) {
+$sqldump .= "\n-- --------------------------------------------------------\n"; }
 ++$kazuki_p; }
 if($numz===0) {
-echo "--\n";
-echo "-- Dumping data for table \"".$TableNames[$renee_s]."\"\n";
-echo "--\n\n";
-echo "\n-- --------------------------------------------------------\n"; }
-echo "\n";
-++$renee_s; }
+$sqldump .= "--\n";
+$sqldump .= "-- Dumping data for table \"".$TableNames[$melanie_p]."\"\n";
+$sqldump .= "--\n\n";
+$sqldump .= "\n-- --------------------------------------------------------\n"; }
+$sqldump .= "\n";
+++$melanie_p; }
+if($_GET['compress']=="none") { echo $sqldump; }
+if($_GET['compress']=="gzencode") { echo gzencode($sqldump,$_GET['comlevel']); }
+if($_GET['compress']=="gzcompress") { echo gzcompress($sqldump,$_GET['comlevel']); }
+if($_GET['compress']=="gzdeflate") { echo gzdeflate($sqldump,$_GET['comlevel']); }
+if($_GET['compress']=="bzcompress") { echo bzcompress($sqldump,$_GET['comlevel']); }
 fix_amp($Settings['use_gzip'],$GZipEncode['Type']);
 ?>