OSDN Git Service

Added SQL Dumper. :P
authorKazuki Przyborowski <kazuki.przyborowski@gmail.com>
Sat, 30 May 2009 07:34:35 +0000 (07:34 +0000)
committerKazuki Przyborowski <kazuki.przyborowski@gmail.com>
Sat, 30 May 2009 07:34:35 +0000 (07:34 +0000)
git-svn-id: svn://svn.code.sf.net/p/intdb/svn/trunk@254 2b68903e-0b30-0410-9a39-a2e4f3c5be39

inc/admin/sqldumper.php [new file with mode: 0644]
inc/admin/table.php
inc/versioninfo.php
preindex.php

diff --git a/inc/admin/sqldumper.php b/inc/admin/sqldumper.php
new file mode 100644 (file)
index 0000000..bc579bf
--- /dev/null
@@ -0,0 +1,137 @@
+<?php
+/*
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the Revised BSD License.
+
+    This program 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
+    Revised BSD License for more details.
+
+    Copyright 2004-2009 Cool Dude 2k - http://idb.berlios.de/
+    Copyright 2004-2009 Game Maker 2k - http://intdb.sourceforge.net/
+
+    $FileInfo: sqldumper.php - Last Update: 5/30/2009 SVN 254 - Author: cooldude2k $
+*/
+$File3Name = basename($_SERVER['SCRIPT_NAME']);
+if ($File3Name=="sqldumper.php"||$File3Name=="/sqldumper.php") {
+       require('index.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));
+ob_clean(); @header("Content-Type: text/plain; charset=".$Settings['charset']);
+gzip_page($Settings['use_gzip'],$GZipEncode['Type']); @mysql_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");
+header("Content-Type: application/octet-stream");
+header("Content-Transfer-Encoding: binary");
+function GetAllRows($table) { $rene_j = 0; $trowout = null;
+$tresult = mysql_query("SELECT * FROM `".$table."`");
+while ($trow = mysql_fetch_array($tresult, MYSQL_ASSOC)) {
+$trowout[$rene_j] = $trow;
+++$rene_j; }
+@mysql_free_result($tresult);
+return $trowout; }
+$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_map("add_prefix",$TableChCk);
+if(!isset($_GET['outtype'])||$_GET['outtype']=="UTF-8") {
+@header("Content-Type: text/plain; charset=UTF-8"); }
+if($_GET['outtype']=="latin1") {
+@header("Content-Type: text/plain; charset=ISO-8859-15"); }
+if($_GET['outtype']=="latin15") {
+@header("Content-Type: text/plain; charset=ISO-8859-15"); }
+$sql = "SHOW TABLES LIKE '".$Settings['sqltable']."%'";
+$result = mysql_query($sql);
+if (!$result) {
+echo "DB Error, could not list tables\n";
+echo 'MySQL Error: ' . mysql_error();
+exit; }
+$DropTable = null; $CreateTable = null; $TableNames = null; $l = 0;
+while ($row = mysql_fetch_row($result)) { 
+if(in_array($row[0],$TableChCk)) {
+$TableNames[$l] = $row[0];
+$DropTable[$l] = "DROP TABLE IF EXISTS `".$row[0]."`;\n";
+$CreateTable[$l] = "CREATE TABLE `".$row[0]."` (\n";
+$result2 = mysql_query("SHOW COLUMNS FROM ".$row[0]);
+$tabsta = mysql_query("SHOW TABLE STATUS LIKE '".$row[0]."'");
+$tabstats = mysql_fetch_array($tabsta); $AutoIncrement = " ";
+if($tabstats["Auto_increment"]!="") {
+$AutoIncrement = " AUTO_INCREMENT=".$tabstats["Auto_increment"]." "; }
+       $TableInfo[$l] = null; $TableStats = null; $i = 0;
+       while ($row2 = mysql_fetch_assoc($result2)) {
+               if($row2["Default"]=="") { $row2["Default"] = "''"; }
+               if($i==0) { $row2["Default"] = null; } $DefaVaule = null;
+               if($row2["Default"]!=null) { $DefaVaule = " default ".$row2["Default"]; }
+               if($row2["Extra"]!="") { $row2["Extra"] = " ".$row2["Extra"]; }
+        $TableInfo[$l] .= "  `".$row2["Field"]."` ".$row2["Type"]." NOT NULL".$DefaVaule.$row2["Extra"].",\n";
+               if($row2["Key"]=="PRI") { $PrimaryKey[$l] = "  PRIMARY KEY  (`".$row2["Field"]."`)"; }
+       ++$i; } 
+       $TableStats[$l] = ") TYPE=".$tabstats["Engine"]." DEFAULT CHARSET=".mysql_client_encoding().$AutoIncrement.";\n";
+       $TableInfo[$l] .= $PrimaryKey[$l]."\n".$TableStats[$l];
+       $FullTable[$l] = $DropTable[$l].$CreateTable[$l].$TableInfo[$l]; }
+if (!$result2) {
+    echo 'Could not run query: ' . mysql_error();
+    exit; }
+@mysql_free_result($result2);
+@mysql_free_result($tabsta);
+++$l; } $tableout = null;
+$num = count($TableNames); $renee_s = 0;
+echo "-- iDB SQL Dumper\n";
+echo "-- version ".$VerInfo['iDB_Ver_SVN']."\n";
+echo "-- http://idb.berlios.de/support/\n";
+echo "--\n";
+echo "-- Host: ".$Settings['sqlhost']."\n";
+echo "-- Generation Time: ".GMTimeGet('F d, Y \a\t h:i A',$_SESSION['UserTimeZone'],0,$_SESSION['UserDST'])."\n";
+echo "-- Server version: ".mysql_get_server_info()."\n";
+echo "-- PHP Version: ".phpversion()."\n";
+while ($renee_s < $num) { $tnum = $num - 1;
+$trow = GetAllRows($TableNames[$renee_s]);
+$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";
+while ($kazuki_p < $numz) { $tnumz = $numz - 1;
+$srow = null; $srowvalue = null;
+$trownew = $trow[$kazuki_p];
+$trowname = array_keys($trownew);
+$nums = count($trownew); $il = 0;
+while ($il < $nums) { $tnums = $nums - 1;
+$trowrname = mysql_real_escape_string($trowname[$il]);
+$trowrvalue = mysql_real_escape_string($trownew[$trowrname]);
+if($_GET['outtype']=="UTF-8") {
+$trowrvalue = utf8_encode($trowrvalue); }
+$trowrvalue = str_replace( array("\n", "\r"), array('\n', '\r'), $trowrvalue);
+if($kazuki_p==0) {
+if($il==0) { $srow = "INSERT DELAYED IGNORE INTO `".$TableNames[$renee_s]."` ("; }
+if($il<$tnums&&$il!=$tnums) { $srow .= "`".$trowrname."`,"; }
+if($il==$tnums) { $srow .= "`".$trowrname."`) VALUES"; } }
+if($il==0) { $srowvalue = "("; }
+if(!is_numeric($trowrvalue)) { $trowrvalue = "'".$trowrvalue."'"; }
+if($il<$tnums) { $srowvalue .= $trowrvalue.","; }
+if($il==$tnums) { $srowvalue .= $trowrvalue;
+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"; }
+++$kazuki_p; }
+echo "\n";
+++$renee_s; }
+fix_amp($Settings['use_gzip'],$GZipEncode['Type']);
+?>
index 0bfc179..2ad963c 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2008 Cool Dude 2k - http://idb.berlios.de/
     Copyright 2004-2008 Game Maker 2k - http://intdb.sourceforge.net/
 
-    $FileInfo: table.php - Last Update: 12/12/2008 SVN 215 - Author: cooldude2k $
+    $FileInfo: table.php - Last Update: 5/30/2009 SVN 254 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="table.php"||$File3Name=="/table.php") {
@@ -36,6 +36,8 @@ if ($File3Name=="table.php"||$File3Name=="/table.php") {
 <?php if($GroupInfo['ViewDBInfo']=="yes") { ?>
 </tr><tr class="TableSMenuRow3">
 <td class="TableSMenuColumn3"><a href="<?php echo url_maker($exfile['admin'],$Settings['file_ext'],"act=mysql",$Settings['qstr'],$Settings['qsep'],$prexqstr['admin'],$exqstr['admin']); ?>">MySQL Settings</a></td>
+</tr><tr class="TableSMenuRow3">
+<td class="TableSMenuColumn3"><a href="<?php echo url_maker($exfile['admin'],$Settings['file_ext'],"act=sqldumper",$Settings['qstr'],$Settings['qsep'],$prexqstr['admin'],$exqstr['admin']); ?>">SQL Dumper</a></td>
 <?php } ?>
 </tr><tr class="TableSMenuRow3">
 <td class="TableSMenuColumn3"><a href="<?php echo url_maker($exfile['admin'],$Settings['file_ext'],"act=info",$Settings['qstr'],$Settings['qsep'],$prexqstr['admin'],$exqstr['admin']); ?>">Edit Board Info</a></td>
index 2f90685..35178a9 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2009 Cool Dude 2k - http://idb.berlios.de/
     Copyright 2004-2009 Game Maker 2k - http://intdb.sourceforge.net/
 
-    $FileInfo: versioninfo.php - Last Update: 5/14/2009 SVN 253 - Author: cooldude2k $
+    $FileInfo: versioninfo.php - Last Update: 5/30/2009 SVN 254 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="versioninfo.php"||$File3Name=="/versioninfo.php") {
@@ -27,8 +27,8 @@ function version_info($proname,$subver,$ver,$supver,$reltype,$svnver,$showsvn) {
        return $return_var; }
 // Version number and date stuff. :P
 $VER1[0] = 0; $VER1[1] = 2; $VER1[2] = 7; $VERFull[1] = $VER1[0].".".$VER1[1].".".$VER1[2];
-$VER2[0] = "Pre-Alpha"; $VER2[1] = "PA"; $VER2[2] = "SVN"; $SubVerN = 253; $RName = "iDB"; $SFName = "IntDB";
-$SVNDay[0] = 5; $SVNDay[1] = 14; $SVNDay[2] = 2009; $SVNDay[3] = $SVNDay[0]."/".$SVNDay[1]."/".$SVNDay[2];
+$VER2[0] = "Pre-Alpha"; $VER2[1] = "PA"; $VER2[2] = "SVN"; $SubVerN = 254; $RName = "iDB"; $SFName = "IntDB";
+$SVNDay[0] = 5; $SVNDay[1] = 30; $SVNDay[2] = 2009; $SVNDay[3] = $SVNDay[0]."/".$SVNDay[1]."/".$SVNDay[2];
 $VerInfo['iDB_Ver'] = version_info($RName,$VER1[0],$VER1[1],$VER1[2],$VER2[1],$SubVerN,false);
 $VerInfo['iDB_Ver_SVN'] = version_info($RName,$VER1[0],$VER1[1],$VER1[2],$VER2[1],$SubVerN,true);
 $VerInfo['iDB_Full_Ver'] = version_info($RName,$VER1[0],$VER1[1],$VER1[2],$VER2[0],$SubVerN,false);
index 658cce9..9312fc7 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2009 Cool Dude 2k - http://idb.berlios.de/
     Copyright 2004-2009 Game Maker 2k - http://intdb.sourceforge.net/
 
-    $FileInfo: preindex.php - Last Update: 5/01/2009 SVN 247 - Author: cooldude2k $
+    $FileInfo: preindex.php - Last Update: 5/30/2009 SVN 254 - Author: cooldude2k $
 */
 $pretime = explode(" ", microtime());
 $utime = $pretime[0];
@@ -22,6 +22,8 @@ if ($File3Name=="preindex.php"||$File3Name=="/preindex.php") {
        @header('Location: index.php');
        exit(); }
 require('mysql.php');
+if($_GET['act']=="sqldumper"&&$_SESSION['UserGroup']!=$Settings['GuestGroup']&&
+       $GroupInfo['HasAdminCP']=="yes") { require($SettDir['admin'].'sqldumper.php'); die(); }
 if(!isset($checklowview)) {
        $checklowview = false; }
 if($checklowview!==false&&$checklowview!==true) {