OSDN Git Service

Added PostgreSQL dumper.
authorKazuki Przyborowski <kazuki.przyborowski@gmail.com>
Tue, 15 Dec 2009 00:04:50 +0000 (00:04 +0000)
committerKazuki Przyborowski <kazuki.przyborowski@gmail.com>
Tue, 15 Dec 2009 00:04:50 +0000 (00:04 +0000)
git-svn-id: svn://svn.code.sf.net/p/intdb/svn/trunk@406 2b68903e-0b30-0410-9a39-a2e4f3c5be39

inc/admin/sqldumper/pgsql.php [new file with mode: 0644]
inc/admin/sqldumper/sqlite.php
inc/admin/table.php
inc/misc/sql/pgsql.php
inc/versioninfo.php
preindex.php
setup/sql/pgsql.php

diff --git a/inc/admin/sqldumper/pgsql.php b/inc/admin/sqldumper/pgsql.php
new file mode 100644 (file)
index 0000000..0874c19
--- /dev/null
@@ -0,0 +1,154 @@
+<?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 iDB Support - http://idb.berlios.de/
+    Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
+
+    $FileInfo: sqlite.php - Last Update: 12/14/2009 SVN 406 - Author: cooldude2k $
+*/
+$File3Name = basename($_SERVER['SCRIPT_NAME']);
+if ($File3Name=="sqlite.php"||$File3Name=="/sqlite.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']); session_write_close(); die(); }
+if($Settings['sqltype']!="pgsql") {
+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']); 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");
+header("Content-Type: application/octet-stream");
+header("Content-Transfer-Encoding: binary");
+$SQLDumper = "SQL Dumper";
+function GetAllRows($table) { $rene_j = 0; $trowout = null;
+global $SQLStat;
+$tresult = sql_query("SELECT * FROM \"".$table."\"",$SQLStat);
+while ($trow = sql_fetch_assoc($tresult)) {
+$trowout[$rene_j] = $trow;
+++$rene_j; }
+sql_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"); }
+$sli = 0; $slnum = count($TableChCk);
+while ($sli < $slnum) {
+$FullTable[$sli] = "CREATE TABLE \"".$TableChCk[$sli]."\" (";
+$tabsta = sql_query("select * from information_schema.columns where table_name='".$TableChCk[$sli]."';",$SQLStat);
+$zli = 0; $zlnum = sql_num_rows($tabsta);
+$UniKeyRow = null;
+while ($zli < $zlnum) {
+$SQL['column_name'] = sql_result($tabsta,$zli,"column_name");
+$SQL['column_default'] = sql_result($tabsta,$zli,"column_default");
+$PSQL = null;
+$PSQL = explode("::", $SQL['column_default']);
+if(count($PSQL)>1) { $SQL['column_default'] = $PSQL[0]; }
+if (preg_match("/nextval(.*)\_seq/i", $SQL['column_default'])) {
+$SQL['udt_name'] = "SERIAL"; $SQL['column_default'] = null;
+} else { $SQL['column_default'] = " DEFAULT ".$SQL['column_default'];
+$SQL['udt_name'] = sql_result($tabsta,$zli,"udt_name"); }
+if($SQL['udt_name']=="text") { $SQL['column_default'] = null; }
+$SQL['character_maximum_length'] = sql_result($tabsta,$zli,"character_maximum_length");
+if($SQL['udt_name']=="varchar") {
+       $SQL['udt_name'] = $SQL['udt_name']."(".$SQL['character_maximum_length'].")"; }
+$pristats = null; $PriKeyRow = " ";
+$prista = sql_query("SELECT * FROM information_schema.key_column_usage WHERE table_name = '".$TableChCk[$sli]."' and column_name = '".$SQL['column_name']."';",$SQLStat);
+$pristats = @pg_fetch_result($prista,0,"\"constraint_name\"");
+if (preg_match("/(.*)\_pkey/i", $pristats)) {
+$PriKeyRow = " PRIMARY KEY ";
+} else {
+if (preg_match("/(.*)\_key/i", $pristats)) {
+$UniKeyRow = $UniKeyRow.",\n  UNIQUE (\"".$SQL['column_name']."\")";
+} else {
+/*Nothing*/ } }
+if($pristats==$SQL['column_name']) { $PriKeyRow = " PRIMARY KEY "; }
+$FullTable[$sli] .= "\n  \"".$SQL['column_name']."\" ".$SQL['udt_name'].$PriKeyRow."NOT NULL".$SQL['column_default'];
+if($zli+1 < $zlnum) { $FullTable[$sli] .= ","; }
+++$zli; }
+$FullTable[$sli] .= $UniKeyRow."\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 "-- 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: ".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]);
+$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 = sql_escape_string($trowname[$il],$SQLStat);
+$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($kazuki_p===0) {
+if($il===0) { $srow = "INSERT 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; }
+if($numz===0) {
+echo "--\n";
+echo "-- Dumping data for table \"".$TableNames[$renee_s]."\"\n";
+echo "--\n\n";
+echo "\n-- --------------------------------------------------------\n"; }
+echo "\n";
+++$renee_s; }
+fix_amp($Settings['use_gzip'],$GZipEncode['Type']);
+?>
index f44382d..7b03dea 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2009 iDB Support - http://idb.berlios.de/
     Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: sqlite.php - Last Update: 12/14/2009 SVN 405 - Author: cooldude2k $
+    $FileInfo: sqlite.php - Last Update: 12/14/2009 SVN 406 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="sqlite.php"||$File3Name=="/sqlite.php") {
@@ -52,10 +52,9 @@ $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-1"); }
+header("Content-Type: text/plain; charset=ISO-8859-15"); }
 if($_GET['outtype']=="latin15") {
 header("Content-Type: text/plain; charset=ISO-8859-15"); }
-if($Settings['sqltype']=="sqlite") {
 $sli = 0; $slnum = count($TableChCk);
 while ($sli < $slnum) {
 $FullTable[$sli] = "CREATE TABLE \"".$TableChCk[$sli]."\" (\n";
@@ -74,7 +73,7 @@ $FullTable[$sli] .= "  \"".$tabstats['name']."\" ".$tabstats['type'].$PrimeKey."
 ++$zli; }
 $FullTable[$sli] .= "\n);\n";
 ++$sli; }
-$TableNames = $TableChCk; }
+$TableNames = $TableChCk;
 $num = count($TableNames); $renee_s = 0;
 echo "-- ".$OrgName." ".$SQLDumper."\n";
 echo "-- version ".$VerInfo['iDB_Ver_SVN']."\n";
index 5c6fb51..3bd40c0 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2009 iDB Support - http://idb.berlios.de/
     Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: table.php - Last Update: 12/13/2009 SVN 403 - Author: cooldude2k $
+    $FileInfo: table.php - Last Update: 12/14/2009 SVN 406 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="table.php"||$File3Name=="/table.php") {
@@ -65,6 +65,7 @@ if ($File3Name=="table.php"||$File3Name=="/table.php") {
 </tr><tr class="TableSMenuRow3">
 <?php if($Settings['sqltype']=="mysql"||
        $Settings['sqltype']=="mysqli"||
+       $Settings['sqltype']=="pgsql"||
        $Settings['sqltype']=="sqlite") { ?>
 <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 } ?>
index 7f0f0be..52edf76 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2009 iDB Support - http://idb.berlios.de/
     Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: pgsql.php - Last Update: 12/13/2009 SVN 404 - Author: cooldude2k $
+    $FileInfo: pgsql.php - Last Update: 12/14/2009 SVN 406 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="pgsql.php"||$File3Name=="/pgsql.php") {
@@ -120,7 +120,7 @@ if(isset($link)) {
        $result = pg_version($link); }
 if(!isset($link)) {
        $result = pg_version(); }
-       return $result; }
+       return $result['server']; }
 function sql_escape_string($string,$link=null) {
 global $SQLStat;
 if(!isset($link)) { $link = $SQLStat; }
index 05298b1..f64dad8 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2009 iDB Support - http://idb.berlios.de/
     Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: versioninfo.php - Last Update: 12/14/2009 SVN 405 - Author: cooldude2k $
+    $FileInfo: versioninfo.php - Last Update: 12/14/2009 SVN 406 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="versioninfo.php"||$File3Name=="/versioninfo.php") {
@@ -27,7 +27,7 @@ function version_info($proname,$subver,$ver,$supver,$reltype,$svnver,$showsvn) {
        return $return_var; }
 // Version number and date stuff. :P
 $VER1[0] = 0; $VER1[1] = 3; $VER1[2] = 4; $VERFull[1] = $VER1[0].".".$VER1[1].".".$VER1[2];
-$VER2[0] = "Alpha"; $VER2[1] = "Al"; $VER2[2] = "SVN"; $SubVerN = 405; $RName = "iDB"; $SFName = "IntDB";
+$VER2[0] = "Alpha"; $VER2[1] = "Al"; $VER2[2] = "SVN"; $SubVerN = 406; $RName = "iDB"; $SFName = "IntDB";
 $SVNDay[0] = 12; $SVNDay[1] = 14; $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);
index c38821e..889b819 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2009 iDB Support - http://idb.berlios.de/
     Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: preindex.php - Last Update: 12/13/2009 SVN 404 - Author: cooldude2k $
+    $FileInfo: preindex.php - Last Update: 12/14/2009 SVN 406 - Author: cooldude2k $
 */
 $pretime = explode(" ", microtime());
 $utime = $pretime[0];
@@ -26,6 +26,8 @@ if($_GET['act']=="sqldumper"&&$_SESSION['UserGroup']!=$Settings['GuestGroup']&&
        $GroupInfo['HasAdminCP']=="yes") { 
        if($Settings['sqltype']=="mysql"||$Settings['sqltype']=="mysqli") {
        require($SettDir['sqldumper'].'mysql.php'); }
+       if($Settings['sqltype']=="pgsql") {
+       require($SettDir['sqldumper'].'pgsql.php'); } 
        if($Settings['sqltype']=="sqlite") {
        require($SettDir['sqldumper'].'sqlite.php'); } 
        session_write_close(); die(); }
index 84fbb75..89dd429 100644 (file)
@@ -12,7 +12,7 @@
     Copyright 2004-2009 Game Maker 2k - http://gamemaker2k.org/
     iDB Installer made by Game Maker 2k - http://idb.berlios.net/
 
-    $FileInfo: pgsql.php - Last Update: 12/13/2009 SVN 404 - Author: cooldude2k $
+    $FileInfo: pgsql.php - Last Update: 12/14/2009 SVN 406 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="pgsql.php"||$File3Name=="/pgsql.php") {
@@ -26,14 +26,14 @@ sql_query($query,$SQLStat);
 */
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."categories\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"OrderID\" int NOT NULL default '0',\n".
+"  \"OrderID\" int4 NOT NULL default '0',\n".
 "  \"Name\" varchar(150) NOT NULL default '',\n".
 "  \"ShowCategory\" varchar(5) NOT NULL default '',\n".
 "  \"CategoryType\" varchar(15) NOT NULL default '',\n".
 "  \"SubShowForums\" varchar(5) NOT NULL default '',\n".
-"  \"InSubCategory\" int NOT NULL default '0',\n".
-"  \"PostCountView\" int NOT NULL default '0',\n".
-"  \"KarmaCountView\" int NOT NULL default '0',\n".
+"  \"InSubCategory\" int4 NOT NULL default '0',\n".
+"  \"PostCountView\" int4 NOT NULL default '0',\n".
+"  \"KarmaCountView\" int4 NOT NULL default '0',\n".
 "  \"Description\" text NOT NULL\n".
 ");", array(null));
 sql_query($query,$SQLStat);
@@ -42,9 +42,9 @@ $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."categories\" (\"O
 sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."catpermissions\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"PermissionID\" int NOT NULL default '0',\n".
+"  \"PermissionID\" int4 NOT NULL default '0',\n".
 "  \"Name\" varchar(150) NOT NULL default '',\n".
-"  \"CategoryID\" int NOT NULL default '0',\n".
+"  \"CategoryID\" int4 NOT NULL default '0',\n".
 "  \"CanViewCategory\" varchar(5) NOT NULL default ''\n".
 ");", array(null));
 sql_query($query,$SQLStat);
@@ -58,18 +58,18 @@ $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."catpermissions\"
 sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."events\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"UserID\" int NOT NULL default '0',\n".
+"  \"UserID\" int4 NOT NULL default '0',\n".
 "  \"GuestName\" varchar(150) NOT NULL default '',\n".
 "  \"EventName\" varchar(150) NOT NULL default '',\n".
 "  \"EventText\" text NOT NULL,\n".
-"  \"TimeStamp\" int NOT NULL default '0',\n".
-"  \"TimeStampEnd\" int NOT NULL default '0',\n".
-"  \"EventMonth\" int NOT NULL default '0',\n".
-"  \"EventMonthEnd\" int NOT NULL default '0',\n".
-"  \"EventDay\" int NOT NULL default '0',\n".
-"  \"EventDayEnd\" int NOT NULL default '0',\n".
-"  \"EventYear\" int NOT NULL default '0',\n".
-"  \"EventYearEnd\" int NOT NULL default '0'\n".
+"  \"TimeStamp\" int4 NOT NULL default '0',\n".
+"  \"TimeStampEnd\" int4 NOT NULL default '0',\n".
+"  \"EventMonth\" int4 NOT NULL default '0',\n".
+"  \"EventMonthEnd\" int4 NOT NULL default '0',\n".
+"  \"EventDay\" int4 NOT NULL default '0',\n".
+"  \"EventDayEnd\" int4 NOT NULL default '0',\n".
+"  \"EventYear\" int4 NOT NULL default '0',\n".
+"  \"EventYearEnd\" int4 NOT NULL default '0'\n".
 ");", array(null));
 sql_query($query,$SQLStat);
 $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."events\" (\"UserID\", \"GuestName\", \"EventName\", \"EventText\", \"TimeStamp\", \"TimeStampEnd\", \"EventMonth\", \"EventMonthEnd\", \"EventDay\", \"EventDayEnd\", \"EventYear\", \"EventYearEnd\") VALUES\n".
@@ -77,23 +77,23 @@ $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."events\" (\"UserI
 sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."forums\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"CategoryID\" int NOT NULL default '0',\n".
-"  \"OrderID\" int NOT NULL default '0',\n".
+"  \"CategoryID\" int4 NOT NULL default '0',\n".
+"  \"OrderID\" int4 NOT NULL default '0',\n".
 "  \"Name\" varchar(150) NOT NULL default '',\n".
 "  \"ShowForum\" varchar(5) NOT NULL default '',\n".
 "  \"ForumType\" varchar(15) NOT NULL default '',\n".
-"  \"InSubForum\" int NOT NULL default '0',\n".
+"  \"InSubForum\" int4 NOT NULL default '0',\n".
 "  \"RedirectURL\" text NOT NULL,\n".
-"  \"Redirects\" int NOT NULL default '0',\n".
-"  \"NumViews\" int NOT NULL default '0',\n".
+"  \"Redirects\" int4 NOT NULL default '0',\n".
+"  \"NumViews\" int4 NOT NULL default '0',\n".
 "  \"Description\" text NOT NULL,\n".
 "  \"PostCountAdd\" varchar(15) NOT NULL default '',\n".
-"  \"PostCountView\" int NOT NULL default '0',\n".
-"  \"KarmaCountView\" int NOT NULL default '0',\n".
+"  \"PostCountView\" int4 NOT NULL default '0',\n".
+"  \"KarmaCountView\" int4 NOT NULL default '0',\n".
 "  \"CanHaveTopics\" varchar(5) NOT NULL default '',\n".
-"  \"HotTopicPosts\" int NOT NULL default '0',\n".
-"  \"NumPosts\" int NOT NULL default '0',\n".
-"  \"NumTopics\" int NOT NULL default '0'\n".
+"  \"HotTopicPosts\" int4 NOT NULL default '0',\n".
+"  \"NumPosts\" int4 NOT NULL default '0',\n".
+"  \"NumTopics\" int4 NOT NULL default '0'\n".
 ");", array(null));
 sql_query($query,$SQLStat);
 $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."forums\" (\"CategoryID\", \"OrderID\", \"Name\", \"ShowForum\", \"ForumType\", \"InSubForum\", \"RedirectURL\", \"Redirects\", \"NumViews\", \"Description\", \"PostCountAdd\", \"PostCountView\", \"KarmaCountView\", \"CanHaveTopics\", \"HotTopicPosts\", \"NumPosts\", \"NumTopics\") VALUES\n".
@@ -102,7 +102,7 @@ sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."groups\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
 "  \"Name\" varchar(150) NOT NULL default '',\n".
-"  \"PermissionID\" int NOT NULL default '0',\n".
+"  \"PermissionID\" int4 NOT NULL default '0',\n".
 "  \"NamePrefix\" varchar(150) NOT NULL default '',\n".
 "  \"NameSuffix\" varchar(150) NOT NULL default '',\n".
 "  \"CanViewBoard\" varchar(5) NOT NULL default '',\n".
@@ -111,11 +111,11 @@ $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."groups\" (\n".
 "  \"CanAddEvents\" varchar(5) NOT NULL default '',\n".
 "  \"CanPM\" varchar(5) NOT NULL default '',\n".
 "  \"CanSearch\" varchar(5) NOT NULL default '',\n".
-"  \"FloodControl\" int NOT NULL default '0',\n".
-"  \"SearchFlood\" int NOT NULL default '0',\n".
-"  \"PromoteTo\" int NOT NULL default '0',\n".
-"  \"PromotePosts\" int NOT NULL default '0',\n".
-"  \"PromoteKarma\" int NOT NULL default '0',\n".
+"  \"FloodControl\" int4 NOT NULL default '0',\n".
+"  \"SearchFlood\" int4 NOT NULL default '0',\n".
+"  \"PromoteTo\" int4 NOT NULL default '0',\n".
+"  \"PromotePosts\" int4 NOT NULL default '0',\n".
+"  \"PromoteKarma\" int4 NOT NULL default '0',\n".
 "  \"HasModCP\" varchar(5) NOT NULL default '',\n".
 "  \"HasAdminCP\" varchar(5) NOT NULL default '',\n".
 "  \"ViewDBInfo\" varchar(5) NOT NULL default '',\n".
@@ -136,31 +136,31 @@ $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."members\" (\n".
 "  \"UserPassword\" varchar(250) NOT NULL default '',\n".
 "  \"HashType\" varchar(50) NOT NULL default '',\n".
 "  \"Email\" varchar(150) NOT NULL default '',\n".
-"  \"GroupID\" int NOT NULL default '0',\n".
+"  \"GroupID\" int4 NOT NULL default '0',\n".
 "  \"Validated\" varchar(20) NOT NULL default '',\n".
 "  \"HiddenMember\" varchar(20) NOT NULL default '',\n".
-"  \"WarnLevel\" int NOT NULL default '0',\n".
+"  \"WarnLevel\" int4 NOT NULL default '0',\n".
 "  \"Interests\" varchar(150) NOT NULL default '',\n".
 "  \"Title\" varchar(150) NOT NULL default '',\n".
-"  \"Joined\" int NOT NULL default '0',\n".
-"  \"LastActive\" int NOT NULL default '0',\n".
-"  \"LastPostTime\" int NOT NULL default '0',\n".
-"  \"BanTime\" int NOT NULL default '0',\n".
-"  \"BirthDay\" int NOT NULL default '0',\n".
-"  \"BirthMonth\" int NOT NULL default '0',\n".
-"  \"BirthYear\" int NOT NULL default '0',\n".
+"  \"Joined\" int4 NOT NULL default '0',\n".
+"  \"LastActive\" int4 NOT NULL default '0',\n".
+"  \"LastPostTime\" int4 NOT NULL default '0',\n".
+"  \"BanTime\" int4 NOT NULL default '0',\n".
+"  \"BirthDay\" int4 NOT NULL default '0',\n".
+"  \"BirthMonth\" int4 NOT NULL default '0',\n".
+"  \"BirthYear\" int4 NOT NULL default '0',\n".
 "  \"Signature\" text NOT NULL,\n".
 "  \"Notes\" text NOT NULL,\n".
 "  \"Avatar\" varchar(150) NOT NULL default '',\n".
 "  \"AvatarSize\" varchar(10) NOT NULL default '',\n".
 "  \"Website\" varchar(150) NOT NULL default '',\n".
 "  \"Gender\" varchar(15) NOT NULL default '',\n".
-"  \"PostCount\" int NOT NULL default '0',\n".
-"  \"Karma\" int NOT NULL default '0',\n".
-"  \"KarmaUpdate\" int NOT NULL default '0',\n".
-"  \"RepliesPerPage\" int NOT NULL default '0',\n".
-"  \"TopicsPerPage\" int NOT NULL default '0',\n".
-"  \"MessagesPerPage\" int NOT NULL default '0',\n".
+"  \"PostCount\" int4 NOT NULL default '0',\n".
+"  \"Karma\" int4 NOT NULL default '0',\n".
+"  \"KarmaUpdate\" int4 NOT NULL default '0',\n".
+"  \"RepliesPerPage\" int4 NOT NULL default '0',\n".
+"  \"TopicsPerPage\" int4 NOT NULL default '0',\n".
+"  \"MessagesPerPage\" int4 NOT NULL default '0',\n".
 "  \"TimeZone\" varchar(5) NOT NULL default '0',\n".
 "  \"DST\" varchar(5) NOT NULL default '0',\n".
 "  \"UseTheme\" varchar(26) NOT NULL default '0',\n".
@@ -176,14 +176,14 @@ $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."members\" (\"id\"
 sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."messenger\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"SenderID\" int NOT NULL default '0',\n".
-"  \"ReciverID\" int NOT NULL default '0',\n".
+"  \"SenderID\" int4 NOT NULL default '0',\n".
+"  \"ReciverID\" int4 NOT NULL default '0',\n".
 "  \"GuestName\" varchar(150) NOT NULL default '',\n".
 "  \"MessageTitle\" varchar(150) NOT NULL default '',\n".
 "  \"MessageText\" text NOT NULL,\n".
 "  \"Description\" text NOT NULL,\n".
-"  \"DateSend\" int NOT NULL default '0',\n".
-"  \"Read\" int NOT NULL default '0'\n".
+"  \"DateSend\" int4 NOT NULL default '0',\n".
+"  \"Read\" int4 NOT NULL default '0'\n".
 ");", array(null));
 sql_query($query,$SQLStat);
 $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."messenger\" (\"SenderID\", \"ReciverID\", \"GuestName\", \"MessageTitle\", \"MessageText\", \"Description\", \"DateSend\", \"Read\") VALUES\n".
@@ -191,9 +191,9 @@ $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."messenger\" (\"Se
 sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."permissions\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"PermissionID\" int NOT NULL default '0',\n".
+"  \"PermissionID\" int4 NOT NULL default '0',\n".
 "  \"Name\" varchar(150) NOT NULL default '',\n".
-"  \"ForumID\" int NOT NULL default '0',\n".
+"  \"ForumID\" int4 NOT NULL default '0',\n".
 "  \"CanViewForum\" varchar(5) NOT NULL default '',\n".
 "  \"CanMakeTopics\" varchar(5) NOT NULL default '',\n".
 "  \"CanMakeReplys\" varchar(5) NOT NULL default '',\n".
@@ -223,14 +223,14 @@ $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."permissions\" (\"
 sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."posts\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"TopicID\" int NOT NULL default '0',\n".
-"  \"ForumID\" int NOT NULL default '0',\n".
-"  \"CategoryID\" int NOT NULL default '0',\n".
-"  \"UserID\" int NOT NULL default '0',\n".
+"  \"TopicID\" int4 NOT NULL default '0',\n".
+"  \"ForumID\" int4 NOT NULL default '0',\n".
+"  \"CategoryID\" int4 NOT NULL default '0',\n".
+"  \"UserID\" int4 NOT NULL default '0',\n".
 "  \"GuestName\" varchar(150) NOT NULL default '',\n".
-"  \"TimeStamp\" int NOT NULL default '0',\n".
-"  \"LastUpdate\" int NOT NULL default '0',\n".
-"  \"EditUser\" int NOT NULL default '0',\n".
+"  \"TimeStamp\" int4 NOT NULL default '0',\n".
+"  \"LastUpdate\" int4 NOT NULL default '0',\n".
+"  \"EditUser\" int4 NOT NULL default '0',\n".
 "  \"EditUserName\" varchar(150) NOT NULL default '',\n".
 "  \"Post\" text NOT NULL,\n".
 "  \"Description\" text NOT NULL,\n".
@@ -255,7 +255,7 @@ sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."sessions\" (\n".
 "  \"session_id\" varchar(150) PRIMARY KEY NOT NULL default '',\n".
 "  \"session_data\" text NOT NULL,\n".
-"  \"expires\" int NOT NULL default '0'\n".
+"  \"expires\" int4 NOT NULL default '0'\n".
 ");", array(null));
 sql_query($query,$SQLStat);
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."smileys\" (\n".
@@ -293,9 +293,9 @@ sql_query($query,$SQLStat);
 /*
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."tagboard\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"UserID\" int NOT NULL default '0',\n".
+"  \"UserID\" int4 NOT NULL default '0',\n".
 "  \"GuestName\" varchar(150) NOT NULL default '',\n".
-"  \"TimeStamp\" int NOT NULL default '0',\n".
+"  \"TimeStamp\" int4 NOT NULL default '0',\n".
 "  \"Post\" text NOT NULL,\n".
 "  \"IP\" varchar(20) NOT NULL default ''
 ");", array(null));
@@ -305,20 +305,20 @@ sql_query($query,$SQLStat);
 */
 $query=sql_pre_query("CREATE TABLE \"".$_POST['tableprefix']."topics\" (\n".
 "  \"id\" SERIAL PRIMARY KEY NOT NULL,\n".
-"  \"ForumID\" int NOT NULL default '0',\n".
-"  \"CategoryID\" int NOT NULL default '0',\n".
-"  \"OldForumID\" int NOT NULL default '0',\n".
-"  \"OldCategoryID\" int NOT NULL default '0',\n".
-"  \"UserID\" int NOT NULL default '0',\n".
+"  \"ForumID\" int4 NOT NULL default '0',\n".
+"  \"CategoryID\" int4 NOT NULL default '0',\n".
+"  \"OldForumID\" int4 NOT NULL default '0',\n".
+"  \"OldCategoryID\" int4 NOT NULL default '0',\n".
+"  \"UserID\" int4 NOT NULL default '0',\n".
 "  \"GuestName\" varchar(150) NOT NULL default '',\n".
-"  \"TimeStamp\" int NOT NULL default '0',\n".
-"  \"LastUpdate\" int NOT NULL default '0',\n".
+"  \"TimeStamp\" int4 NOT NULL default '0',\n".
+"  \"LastUpdate\" int4 NOT NULL default '0',\n".
 "  \"TopicName\" varchar(150) NOT NULL default '',\n".
 "  \"Description\" text NOT NULL,\n".
-"  \"NumReply\" int NOT NULL default '0',\n".
-"  \"NumViews\" int NOT NULL default '0',\n".
-"  \"Pinned\" int NOT NULL default '0',\n".
-"  \"Closed\" int NOT NULL default '0'\n".
+"  \"NumReply\" int4 NOT NULL default '0',\n".
+"  \"NumViews\" int4 NOT NULL default '0',\n".
+"  \"Pinned\" int4 NOT NULL default '0',\n".
+"  \"Closed\" int4 NOT NULL default '0'\n".
 ");", array(null));
 sql_query($query,$SQLStat);
 $query = sql_pre_query("INSERT INTO \"".$_POST['tableprefix']."topics\" (\"ForumID\", \"CategoryID\", \"OldForumID\", \"OldCategoryID\", \"UserID\", \"GuestName\", \"TimeStamp\", \"LastUpdate\", \"TopicName\", \"Description\", \"NumReply\", \"NumViews\", \"Pinned\", \"Closed\") VALUES\n".