OSDN Git Service

Session manager updated.
authorKazuki Przyborowski <kazuki.przyborowski@gmail.com>
Tue, 12 Jul 2011 03:56:47 +0000 (03:56 +0000)
committerKazuki Przyborowski <kazuki.przyborowski@gmail.com>
Tue, 12 Jul 2011 03:56:47 +0000 (03:56 +0000)
Now the page wont refresh to index if session gets deleted and reloads from cookie. :P

git-svn-id: svn://svn.code.sf.net/p/intdb/svn/trunk@705 2b68903e-0b30-0410-9a39-a2e4f3c5be39

inc/prelogin.php
inc/versioninfo.php
setup/mkconfig.php
sql.php

index 0c44eee..e6a1a87 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2004-2011 iDB Support - http://idb.berlios.de/
     Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: prelogin.php - Last Update: 06/14/2011 SVN 672 - Author: cooldude2k $
+    $FileInfo: prelogin.php - Last Update: 07/11/2011 SVN 705 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="prelogin.php"||$File3Name=="/prelogin.php") {
@@ -70,8 +70,8 @@ if($cookieSecure===false) {
 setcookie("MemberName", $YourNameAM, time() + (7 * 86400), $cbasedir, $cookieDomain);
 setcookie("UserID", $YourIDAM, time() + (7 * 86400), $cbasedir, $cookieDomain);
 setcookie("SessPass", $YourPassAM, time() + (7 * 86400), $cbasedir, $cookieDomain); } }
-redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); $urlstatus = 302;
-gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die();
+/*redirect("location",$rbasedir.url_maker($exfile['index'],$Settings['file_ext'],"act=view",$Settings['qstr'],$Settings['qsep'],$prexqstr['index'],$exqstr['index'],false)); $urlstatus = 302;
+gzip_page($Settings['use_gzip'],$GZipEncode['Type']); session_write_close(); die();*/
 } } if($numlog2<=0||$numlog2>1||$BanError=="yes") { session_unset();
 if($cookieDomain==null) {
 setcookie("MemberName", null, GMTimeStamp() - 3600, $cbasedir);
index 82f26c6..622890f 100644 (file)
@@ -11,7 +11,7 @@
     Copyright 2008-2011 iDB Support - http://idb.berlios.de/
     Copyright 2008-2011 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: versioninfo.php - Last Update: 07/10/2011 SVN 704 - Author: cooldude2k $
+    $FileInfo: versioninfo.php - Last Update: 07/11/2011 SVN 705 - 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] = 4; $VER1[2] = 7; $VERFull[1] = $VER1[0].".".$VER1[1].".".$VER1[2];
-$VER2[0] = "Alpha"; $VER2[1] = "Al"; $VER2[2] = "SVN"; $SubVerN = 704;
-$SVNDay[0] = 07; $SVNDay[1] = 10; $SVNDay[2] = 2011; $SVNDay[3] = $SVNDay[0]."/".$SVNDay[1]."/".$SVNDay[2];
+$VER2[0] = "Alpha"; $VER2[1] = "Al"; $VER2[2] = "SVN"; $SubVerN = 705;
+$SVNDay[0] = 07; $SVNDay[1] = 11; $SVNDay[2] = 2011; $SVNDay[3] = $SVNDay[0]."/".$SVNDay[1]."/".$SVNDay[2];
 $AltName = "RDB"; $AltName2 = "ReneeDB"; $RName = "iDB"; $SFName = "IntDB";
 $RFullName = "Internet Discussion Boards"; $AltFullName = "Renee Discussion Boards"; $AltGM2k = "ReneeDB Team";
 $VerCheckName = "iDB"; $AltVerCheckName = "RDB"; $AltiDBHome = "http://duckduckgo.com/?q=ReneeDB";
index b265ae7..8ef47c5 100644 (file)
@@ -12,7 +12,7 @@
     Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
     iDB Installer made by Game Maker 2k - http://idb.berlios.net/
 
-    $FileInfo: mkconfig.php - Last Update: 07/10/2011 SVN 704 - Author: cooldude2k $
+    $FileInfo: mkconfig.php - Last Update: 07/11/2011 SVN 705 - Author: cooldude2k $
 */
 $File3Name = basename($_SERVER['SCRIPT_NAME']);
 if ($File3Name=="mkconfig.php"||$File3Name=="/mkconfig.php") {
@@ -60,6 +60,7 @@ if (!is_writable($checkfile)) {
    @chmod("settings.php",0766); $Error="Yes";
    @chmod("settingsbak.php",0766);
 } else { /* settings.php is writable install iDB. ^_^ */ }
+if (session_id()) { session_destroy(); }
 session_name($_POST['tableprefix']."sess");
 if(preg_match("/\/$/", $_POST['BoardURL'])<1) { 
        $_POST['BoardURL'] = $_POST['BoardURL']."/"; } 
@@ -76,6 +77,7 @@ header("Date: ".gmdate("D, d M Y H:i:s")." GMT");
 header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
 header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
 session_start();
+//@register_shutdown_function("session_write_close");
 if (pre_strlen($_POST['AdminPasswords'])<"3") { $Error="Yes";
 echo "<br />Your password is too small."; }
 if (pre_strlen($_POST['AdminUser'])<"3") { $Error="Yes";
diff --git a/sql.php b/sql.php
index 0e589c3..0a0ae90 100644 (file)
--- a/sql.php
+++ b/sql.php
@@ -11,7 +11,7 @@
     Copyright 2004-2011 iDB Support - http://idb.berlios.de/
     Copyright 2004-2011 Game Maker 2k - http://gamemaker2k.org/
 
-    $FileInfo: sql.php - Last Update: 07/09/2011 SVN 700 - Author: cooldude2k $
+    $FileInfo: sql.php - Last Update: 07/11/2011 SVN 705 - Author: cooldude2k $
 */
 /* Some ini setting changes uncomment if you need them. 
    Display PHP Errors */
@@ -414,9 +414,11 @@ global $sess_save_path;
 $sess_save_path = $save_path;
 return true; }
 //Session Close Function
+$iDBSessCloseDB = true;
 function sql_session_close() {
-global $SQLStat;
-sql_disconnect_db($SQLStat);
+global $SQLStat,$iDBSessCloseDB;
+if($iDBSessCloseDB===true) {
+sql_disconnect_db($SQLStat); }
 return true; }
 //Session Read Function
 function sql_session_read($id) {
@@ -455,6 +457,7 @@ $time = GMTimeStamp() - $maxlifetime;
 //sql_query(sql_pre_query('DELETE FROM \"'.$sqltable.'sessions\" WHERE \"expires\" < UNIX_TIMESTAMP();', array(null)),$SQLStat);
 sql_query(sql_pre_query("DELETE FROM \"".$sqltable."sessions\" WHERE \"expires\" < %i", array($time)),$SQLStat);
 return true; }
+if (session_id()) { session_destroy(); }
 session_set_save_handler("sql_session_open", "sql_session_close", "sql_session_read", "sql_session_write", "sql_session_destroy", "sql_session_gc");
 if($cookieDomain==null) {
 session_set_cookie_params(0, $cbasedir); }
@@ -473,8 +476,19 @@ header("Expires: ".gmdate("D, d M Y H:i:s")." GMT");
 if(!isset($_COOKIE[$Settings['sqltable']."sess"])) {
 $exptime = GMTimeStamp() - ini_get("session.gc_maxlifetime");
 sql_query(sql_pre_query("DELETE FROM \"".$Settings['sqltable']."sessions\" WHERE \"expires\" < %i OR \"ip_address\"='%s' AND \"user_agent\"='%s'", array($exptime,$temp_user_ip,$temp_user_agent)),$SQLStat); }
+if(!isset($_SESSION['CheckCookie'])) {
+if(isset($_COOKIE['SessPass'])&&isset($_COOKIE['MemberName'])) {
+session_set_save_handler("sql_session_open", "sql_session_close", "sql_session_read", "sql_session_write", "sql_session_destroy", "sql_session_gc");
+session_name($Settings['sqltable']."sess");
+session_start();
+$iDBSessCloseDB = false;
+output_reset_rewrite_vars();
+require($SettDir['inc'].'prelogin.php'); 
+session_write_close(); } }
 session_name($Settings['sqltable']."sess");
 session_start();
+$iDBSessCloseDB = true;
+//@register_shutdown_function("session_write_close");
 //header("Set-Cookie: PHPSESSID=" . session_id() . "; path=".$cbasedir);
 output_reset_rewrite_vars();
 if($_GET['act']=="bsdl"||$_GET['act']=="BSDL"||$_GET['act']=="license"||
@@ -508,9 +522,6 @@ if($_GET['act']=="MkCaptcha"||$_GET['act']=="Captcha") {
        $oPhpCaptcha->SetOwnerText("Fake Code: ".$RandNum);
        $oPhpCaptcha->UseColour(true);
        $oPhpCaptcha->Create(); session_write_close(); die(); } }
-if(!isset($_SESSION['CheckCookie'])) {
-if(isset($_COOKIE['SessPass'])&&isset($_COOKIE['MemberName'])) {
-require($SettDir['inc'].'prelogin.php'); } }
 require($SettDir['inc'].'groupsetup.php');
 if($Settings['board_offline']=="on"&&$GroupInfo['CanViewOffLine']!="yes") {
 header("Content-Type: text/plain; charset=".$Settings['charset']); sql_free_result($peresult);