offset=$gmtoffset before=$str after=$tz"); exit; */ return; } //-------------------------------------------- function WriteCfgFile(){ //-------------------------------------------- $rc = 0; $ParmValue = array(); $ParmName = array(); $ParmName[0] = 'sustitle'; $ParmName[1] = 'susname'; $ParmName[2] = 'susmplevels'; $ParmName[3] = 'susdaysofweek'; $ParmName[4] = 'susnodays'; $ParmName[5] = 'susnostatus'; $ParmName[6] = 'susppgame'; $ParmName[7] = 'susmaxgames'; $ParmName[8] = 'susmaxplayers'; $ParmName[9] = 'susnotice'; $ParmName[10] = 'susaccount'; $ParmName[11] = 'susoptions'; $ParmName[12] = 'susguest'; $ParmName[13] = 'sussubeqreg'; $ParmName[14] = 'susnochgs'; $ParmName[15] = 'susnolineslogfile'; $ParmName[16] = 'suscontacts'; $ParmName[17] = 'susnotify'; $ParmName[18] = 'susallowhalfgames'; $ParmName[19] = 'susadminemail'; $ParmName[20] = 'susnotifyadmin'; $ParmName[21] = 'susnotifyonoff'; $ParmName[22] = 'susdopchghour'; $ParmName[23] = 'sustimezone'; $ParmName[24] = 'susremindmsg'; $ParmName[25] = 'susnumguests'; $ParmName[26] = 'susallowguestlogin'; $ParmName[27] = 'sussignupcutoff'; $ParmName[28] = 'susadminwelcome'; $ParmName[29] = 'susadminnewplayer'; $ParmName[30] = 'susshutdown'; $ParmName[31] = 'susacblcolheadings'; $ParmName[32] = 'susremindtime'; $ParmName[33] = 'susnotifytime'; $NumParms = 34; if(LockPlayerFiles(1) < 0) { echo("
WriteCfgFile: Cannot lock player files"); } for($i=0; $i<$NumParms; $i++){ $ParmValue[$i] = $_SESSION[$ParmName[$i]]; } $file = fopen($_SESSION['path_cfgfile'], 'wb'); if($file == FALSE) { $foo = $_SESSION['path_cfgfile']; echo("
Unable to create $foo"); $rc = 10; } else { // echo("
$CfgFile created sucessfully"); for($i=0; $i<$NumParms; $i++) { $rec = $ParmName[$i].'~'.$ParmValue[$i]."\n"; $len = fwrite($file, $rec, strlen($rec)); if($len == FALSE) { $rc = $i+1; } } LockPlayerFiles(0); fclose($file); SetTimeZone(); } return $rc; } //-------------------------------------------- function ReadCfgFile($IncPrefix="../"){ //-------------------------------------------- $foo = $_SESSION['path_cfgfile']; //WriteToLogFile("\nReadCfgFile() at $foo","data"); require $IncPrefix."includes/CfgGlobals.inc.php"; $rc = 0; $cnt=0; if(LockPlayerFiles(1) < 0) { echo("
ReadCfgFile: Cannot lock player files"); } if(file_exists($_SESSION['path_cfgfile'])) { $handle = @fopen($_SESSION['path_cfgfile'], "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); $ndx = strtok($buffer, '~'); $ndx = trim($ndx); $parm = strtok('~'); $parm = trim($parm); //echo "
ndx=$ndx parm=$parm"; $_SESSION[$ndx] = $parm; $cnt++; } fclose($handle); $SUSTitle = $_SESSION['sustitle']; //Title for displayed pages $SUSName = $_SESSION['susname']; //Name of sheet $SUSMPLevels= $_SESSION['susmplevels']; //Master point levels $SUSDaysUsed = str_split($_SESSION['susdaysofweek']);//Days that are allowed for play $SUSNoDays = $_SESSION['susnodays']; //Number of days displayed $SUSNoStatus = $_SESSION['susnostatus']; //Number of days of status in DB $SUSNumPPG = $_SESSION['susppgame']; //Number of players to make a game $SUSMaxGames = $_SESSION['susmaxgames']; //Max number of games per day $SUSMaxPlayers = $_SESSION['susmaxplayers']; //Max players allowed in DB $SUSNotice = $_SESSION['susnotice']; //Notice above first player name $SUSAccount = $_SESSION['susaccount']; //Account status $SUSOptions = $_SESSION['susoptions']; //Options char array $SUSGuest = $_SESSION['susguest']; //guest priority ('reg' or 'sub') $SUSSubEqReg = $_SESSION['sussubeqreg']; //subs equal regulars $SUSNoChgs = $_SESSION['susnochgs']; //number play days no chgs allowed $SUSNoLinesLogfile = $_SESSION['susnolineslogfile']; //number of lines kept in the logfile $SUSContacts = $_SESSION['suscontacts']; //Contacts page avail for admin or all $SUSNotify = $_SESSION['susnotify']; //Notify is default $SUSAllowHalfGames = $_SESSION['susallowhalfgames']; //Allow half games $SUSAdminEmail = $_SESSION['susadminemail']; //Administrator email $SUSNotifyAdmin = $_SESSION['susnotifyadmin']; //Admin gets copy of notifications $SUSNotifyOnOff = $_SESSION['susnotifyonoff']; //Notifications on/off $SUSDOPChgHour = $_SESSION['susdopchghour']; //Hour to rollover day of play if($_SESSION['sustimezone'] == 'GMT-7') { $_SESSION['sustimezone'] = 'America/Phoenix'; } $SUSTimeZone = $_SESSION['sustimezone']; //Time zone for date/time functions $SUSRemindMsg = $_SESSION['susremindmsg']; //Insert for reminder msg $SUSNumGuests = $_SESSION['susnumguests']; //Number of Guests $SUSAllowGuestLogin = $_SESSION['susallowguestlogin']; //Allow guest login $SUSSignupCutoff = $_SESSION['sussignupcutoff']; //Signup cutoff time $SUSAdminWelcome = $_SESSION['susadminwelcome']; //BCC admins on welcome msg $SUSAdminNewPlayer = $_SESSION['susadminnewplayer']; //Email new player to admins $SUSShutdown = $_SESSION['susshutdown']; //System shutdown status $SUSACBLColHeadings = $_SESSION['susacblcolheadings']; //Column heading for ACBL input csv file $SUSRemindTime = $_SESSION['susremindtime']; //Time to send reminder email $SUSNotifyTime = $_SESSION['susnotifytime']; //Time to start sending admin notifications $_SESSION['susmaxtables'] = array(); //Max tables each day of the week $SUSMaxTables = $_SESSION['susmaxtables'] = GetMaxTables($IncPrefix); $nat = 3; //number days of table assignments displayed if($SUSNoDays < $nat) { $nat = $SUSNoDays; } //in assigntables.php $_SESSION['numtabledays'] = $nat; if(strlen($SUSMPLevels) > 0 ) //&& $SUSMPLevels != 0) { $mpl = explode('/', $SUSMPLevels,6); $_SESSION['showlifemasters'] = 0; if($mpl[0] === '*') { $_SESSION['showlifemasters'] = 1; unset($mpl[0]); $mpl = array_values($mpl); } $cnt = count($mpl); $_SESSION['nmplevels'] = $cnt + 1; $_SESSION['mplevels'] = array(); for($i=0; $i<$cnt; $i++) { $_SESSION['mplevels'][$i] = $mpl[$i]; } sort($_SESSION['mplevels'], SORT_NUMERIC); } else { $SUSMPLevels = $_SESSION['susmplevels']= ""; $_SESSION['mplevels'] = array(); $_SESSION['nmplevels'] = 0; } SetTimeZone(); //$SUS= $_SESSION['sus']; //print_r($_SESSION); exit; } else { $foo = $_SESSION['path_cfgfile']; echo ("
Cannot open $foo"); $rc = 20; } } else { // echo ("
$CfgFile does not exist"); $rc = 10; } LockPlayerFiles(0); return $rc; } //-------------------------------------------- function GetMaxTables($IncPrefix){ //-------------------------------------------- require $IncPrefix."includes/CfgGlobals.inc.php"; $maxTables = array(0,0,0,0,0,0,0); $dpw = 0; for($d=0; $d<7; $d++) { if($SUSDaysUsed[$d] != 0) { $dpw++; } } $mt = array(); $mt = explode(',', $SUSMaxGames, 7); $cnt = count($mt); if($cnt > 1) //check for csv string { if($cnt != $dpw) { return FALSE; } else { $i = 0; for($d=0; $d<7; $d++) { if($SUSDaysUsed[$d] != 0) { $maxTables[$d] = ($i<$cnt) ? trim($mt[$i++]) : 0; } } } } else { for($d=0; $d<7; $d++) if($SUSDaysUsed[$d] != 0) { $maxTables[$d] = $mt[0]; } } return $maxTables; } //-------------------------------------------- function GetDemoDBName(){ //-------------------------------------------- $FName ="configfiles/DemoHist.dat"; $JD = cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y")); $Date = getdate(); $Min = trim($Date['hours'] * 60 + $Date['minutes']); $Default = "demo".$JD.$Min; $DBFile = array(); //file name $DBJD = array(); //julian date used $DBMin = array(); //Minutes into the day $DBFile[0] = "demo"; $DBJD[0] = $JD; $DBMin[0] = $Min; $n = 1; $rc = $Default; $ret = 0; if(file_exists($FName)) { $handle = @fopen($FName, "r"); if ($handle) { //echo "
Now-File/JD/Min=$DBFile[0]/$DBJD[0]/$DBMin[0]"; while (!feof($handle)) { //clean out the old file entries $buffer = fgets($handle, 4096); $str = ''; if($buffer == FALSE) { break; } $DBFile[$n] = trim(strtok($buffer, '~')); $DBJD[$n] = trim(strtok('~')); $DBMin[$n] = trim(strtok('~')); //echo "
buffer=$buffer"; //echo "
File/JD/Min=$DBFile[$n]/$DBJD[$n]/$DBMin[$n]"; if($JD > $DBJD[$n]) { //if table older than today $Table = $DBFile[$n].$DBJD[$n].$DBMin[$n]; //drop it $query = "DROP TABLE $Table"; $ret = mysql_query($query); if(!$ret) { $str = mysql_error(); } //echo "
table=$query ($str)
"; $Table = 'configfiles/'.$Table.'.cfg'; unlink($Table); } else { //then table created today if(($DBMin[$n]+60) < $Min) { //if today and older than an hour $Table = $DBFile[$n].$DBJD[$n].$DBMin[$n]; //drop it $query = "DROP TABLE $Table"; $ret = mysql_query($query); if(!$ret) { $str = mysql_error(); } //echo "
table=$query ($str)
"; $Table = 'configfiles/'.$Table.'.cfg'; unlink($Table); } else { $n++; //keep it } } } fclose($handle); } } $file = fopen($FName, 'wb'); if($file == FALSE) { echo("
Unable to create $FName"); } else { // echo("
$CfgFile created sucessfully"); for($i=0; $i<$n; $i++) { $rec = $DBFile[$i].'~'.$DBJD[$i].'~'.$DBMin[$i]."\n"; $len = fwrite($file, $rec, strlen($rec)); } fclose($file); } return $rc; } //-------------------------------------------- function UpdateCountFile($ndxCount){ // $ndxCount 0=>visits 1=>member demo 2=>admin demo 3=>View Description //-------------------------------------------- $FName ="configfiles/Counts.dat"; $CountData = array(0,0,0,0); if(file_exists($FName)) { $handle = @fopen($FName, "r"); if ($handle) { $buffer = fgets($handle, 4096); $CountData[0] = trim(strtok($buffer, '~')); $CountData[1] = trim(strtok('~')); $CountData[2] = trim(strtok('~')); $CountData[3] = trim(strtok('~')); fclose($handle); } } else { $CountData[0] = $CountData[1] =$CountData[2] = 0; } if($ndxCount < 0) { return $CountData; } $CountData[$ndxCount] += 1; $file = fopen($FName, 'wb'); if($file == FALSE) { echo("
Unable to create $FName"); } else { // echo("
$CfgFile created sucessfully"); $rec = $CountData[0].'~'.$CountData[1].'~'.$CountData[2].'~'.$CountData[3]."\n"; $len = fwrite($file, $rec, strlen($rec)); fclose($file); } return $CountData; } //==============PHP End ======================================================== ?>