Jump to content

Recommended Posts

The file I am trying to edit is found here:

 

http://www.hitforthecycle.com/hftc/modules.php?name=Downloads&d_op=getit&lid=8

 

Here is the code:

 

<?php
// Dave Horn's Team Exports Tracker - this simplified version tracks team exports and ST exports
// Visit www.hitforthecycle.com for the best OOTP League on the net
// [email protected] 

// Directions for use of this file
// Set the 5 (line #10-#14) variables below so they are appropriate to your league server set up
// Modify the getTeamName function (line #156) below so the program knows the name of each of your teams

$exportDir = '../www/lineups';   // this must point to the directory where team exports and FA/ST files are stored
$leagueFile = '';  // full path and name to your league file here
$numTeams = 0; // set this equal to the total number of your teams in your league
$L1 = 'Northern League';
$L2 = 'Southern League';


print("<HTML>");
print("<TITLE>Team Export List</TITLE>");
print("<BODY>");

$files = scandir($exportDir);
//print('<pre>');
//print_r($files);
//print('</pre>');



print('<table border="0" width="100%" cellpadding="2" cellspacing="0">');
print('<tr bgcolor="#0E3259">');
$curDate = date("n.d g:ia");
print("<th colspan=\"6\"><font color=\"WHITE\">NABA Team Export File Status - Current Time: $curDate (PST)</font></th>");
print('</tr>');
print('<tr bgcolor="#0E3259">');
print('<th colspan="3"><font color="WHITE">'.$L1.'</font></th>');
print('<th colspan="3"><font color="WHITE">'.$L2.'</font></th>');
print('</tr>');
print('<tr bgcolor="#5E658C">');
print('	<td width=\"25%\"><font color="WHITE">Team</font></td>
				<td width=\"15%\"><font color="WHITE">Export Date</font></td>
				<td width=\"10%\"><font color="WHITE">ST </font></td>
				<td width=\"25%\"><font color="WHITE">Team</font></td>
				<td width=\"15%\"><font color="WHITE">Export Date</font></td>
				<td width=\"10%\"><font color="WHITE">ST </font></td>
print('</tr>');

$basedir = $exportDir;
$base = "Team";
$stbase = "Teamst";
$ext = ".exp";
$fabase = "fat";
$faext = ".dat";

for ($i = 1; $i <= 10; $i++) {
	$NL = $base.$i.$ext;
	$NLST = $stbase.$i.$ext;
	$j = $i + 10;
	$SL = $base.$j.$ext;
	$SLST = $stbase.$j.$ext;

	if (checkDate($NL, $basedir)) {
		print("<tr><td bgcolor=\"#EA947B\">".getTeamName($NL)."</td><td bgcolor=\"#EA947B\">".getFileDate($NL, $basedir)."</td>");
	} else {
		print("<tr><td bgcolor=\"#95D096\">".getTeamName($NL)."</td><td bgcolor=\"#95D096\">".getFileDate($NL, $basedir)."</td>");
	}			

	if (file_exists($NLST)) {
		print("<td><img src=\"checkmark_red.jpg\" border=\"0\"></td>");
	} else {
		print("<td> </td>");
	}


	if (checkDate($SL, $basedir)) {
		print("<td bgcolor=\"#EA947B\">".getTeamName($SL)."</td><td bgcolor=\"#EA947B\">".getFileDate($SL, $basedir)."</td>");
	} else {
		print("<td bgcolor=\"#95D096\">".getTeamName($SL)."</td><td bgcolor=\"#95D096\">".getFileDate($SL, $basedir)."</td>");
	}

	if (file_exists($SLST)) {
		print("<td><img src=\"checkmark_red.jpg\" border=\"0\"></td>");
	} else {
		print("<td> </td>");
	}


	print("</tr>");

}





print("<tr></tr><tr></tr>");

print("<tr><td bgcolor=\"#EA947B\">Team Export Old</td></tr>");
print("<tr><td bgcolor=\"#95D096\">Team Export OK</td></tr>");
print("<tr><td><img src=\"checkmark_red.jpg\" border=\"0\"> File Submitted</td></tr>");
print("<tr><td>ST = Spring Training</td></tr>");




print('</table>');





print("</BODY>");
print("</HTML>");
return;

function checkDate($file, $basedir, $leaguefile) {
	//print(filemtime($leaguefile));

	$teamfile = $basedir.$file;
	if (!file_exists($teamfile)) {
		$teamfile = $basedir.strtoupper($file);
	}

	if (file_exists($teamfile) && file_exists($leaguefile)) {
		//print("here1");
		if (filemtime($leaguefile) > filemtime($teamfile)) {
			return true;
		} else {
			//print("here2");
			return false;
		}
	} else {
		//print("here3");
		return true;
	}
}



function getFileDate($file, $basedir) {
	$teamfile = $basedir.$file;
	//print "looking for $teamfile or ";
	if (file_exists($teamfile)) {
		return date("n.d g:ia", filemtime($teamfile));
	}

	$teamfile = $basedir.strtoupper($file);
	//print "$teamfile <br> ";
	if (file_exists($teamfile)) {
		return date("n.d g:ia", filemtime($teamfile));
	} else {
		return 'No File';
	}
}



function getTeamName($file) {
	$file = strtolower($file);
	switch ($file) {
		case 'team1.exp': return 'Philadelphia';
		case 'team2.exp': return 'Ottawa';
		case 'team3.exp': return 'Toronto';
		case 'team4.exp': return 'Montreal';
		case 'team5.exp': return 'New York';
		case 'team6.exp': return 'Seattle';
		case 'team7.exp': return 'Calgary';
		case 'team8.exp': return 'Chicago';
		case 'team9.exp': return 'Los Angeles';
		case 'team10.exp': return 'Vancouver';
		case 'team11.exp': return 'San Juan';
		case 'team12.exp': return 'Atlanta';
		case 'team13.exp': return 'Monterrey';
		case 'team14.exp': return 'Veracruz';
		case 'team15.exp': return 'Havana';
		case 'team16.exp': return 'Tijuana';
		case 'team17.exp': return 'Cancun';
		case 'team18.exp': return 'Mexico City';
		case 'team19.exp': return 'Houston';
		case 'team20.exp': return 'Tampico';
	}
}

function scandir($dirstr) {
   // php.net/scandir (PHP5)
   $files = array();
   $fh = opendir($dirstr);
   while (false !== ($filename = readdir($fh))) {
       array_push($files, $filename);
   }
   closedir($fh);
   return $files;
}



?>

 

It triggers several breaks...

 

@ line 44'ish (depending on how you copy the code in) - "print('</tr>');" causes an unexpected "/"

 

If that is deleted it causes some errors later in the code...

 

------------------

 

Generally speaking the code is designed for a baseball text sim game callled OOTP, and this is designed as an export tracker. Team owners upload their team changes to a webhost and then this page is designed to check who has uploaded and generate an output...

 

Any help getting this to work would be spectacular.

 

 

Link to comment
https://forums.phpfreaks.com/topic/38908-php-error/
Share on other sites

You don't close the previous "print" statement.

 

Ken

 

Okay that fixed a number of the problems... thanks!!

 

now I am getting a new error here:

 

" } else {

//print("here3");

return true;

}"

 

Says cannot redeclare check date.... and is referring to line 134 which is the last line I copied here

 

The code after you fixed my previous problem:

 

<?php
// Dave Horn's Team Exports Tracker - this simplified version tracks team exports and ST exports
// Visit www.hitforthecycle.com for the best OOTP League on the net
// [email protected]

// Directions for use of this file
// Set the 5 (line #10-#14) variables below so they are appropriate to your league server set up
// Modify the getTeamName function (line #156) below so the program knows the name of each of your teams

$exportDir = '../www/lineups';   // this must point to the directory where team exports and FA/ST files are stored
$leagueFile = '';  // full path and name to your league file here
$numTeams = 0; // set this equal to the total number of your teams in your league
$L1 = 'Northern League';
$L2 = 'Southern League';


print("<HTML>");
print("<TITLE>Team Export List</TITLE>");
print("<BODY>");

$files = scandir($exportDir);
//print('<pre>');
//print_r($files);
//print('</pre>');



print('<table border="0" width="100%" cellpadding="2" cellspacing="0">');
print('<tr bgcolor="#0E3259">');
$curDate = date("n.d g:ia");
print("<th colspan=\"6\"><font color=\"WHITE\">NABA Team Export File Status - Current Time: $curDate (PST)</font></th>");
print('</tr>');
print('<tr bgcolor="#0E3259">');
print('<th colspan="3"><font color="WHITE">'.$L1.'</font></th>');
print('<th colspan="3"><font color="WHITE">'.$L2.'</font></th>');
print('</tr>');
print('<tr bgcolor="#5E658C">');
print('	<td width=\"25%\"><font color="WHITE">Team</font></td>
				<td width=\"15%\"><font color="WHITE">Export Date</font></td>
				<td width=\"10%\"><font color="WHITE">ST </font></td>
				<td width=\"25%\"><font color="WHITE">Team</font></td>
				<td width=\"15%\"><font color="WHITE">Export Date</font></td>
				<td width=\"10%\"><font color="WHITE">ST </font></td>');
print('</tr>');

$basedir = $exportDir;
$base = "Team";
$stbase = "Teamst";
$ext = ".exp";
$fabase = "fat";
$faext = ".dat";

for ($i = 1; $i <= 10; $i++) {
	$NL = $base.$i.$ext;
	$NLST = $stbase.$i.$ext;
	$j = $i + 10;
	$SL = $base.$j.$ext;
	$SLST = $stbase.$j.$ext;

	if (checkDate($NL, $basedir)) {
		print("<tr><td bgcolor=\"#EA947B\">".getTeamName($NL)."</td><td bgcolor=\"#EA947B\">".getFileDate($NL, $basedir)."</td>");
	} else {
		print("<tr><td bgcolor=\"#95D096\">".getTeamName($NL)."</td><td bgcolor=\"#95D096\">".getFileDate($NL, $basedir)."</td>");
	}

	if (file_exists($NLST)) {
		print("<td><img src=\"checkmark_red.jpg\" border=\"0\"></td>");
	} else {
		print("<td> </td>");
	}


	if (checkDate($SL, $basedir)) {
		print("<td bgcolor=\"#EA947B\">".getTeamName($SL)."</td><td bgcolor=\"#EA947B\">".getFileDate($SL, $basedir)."</td>");
	} else {
		print("<td bgcolor=\"#95D096\">".getTeamName($SL)."</td><td bgcolor=\"#95D096\">".getFileDate($SL, $basedir)."</td>");
	}

	if (file_exists($SLST)) {
		print("<td><img src=\"checkmark_red.jpg\" border=\"0\"></td>");
	} else {
		print("<td> </td>");
	}


	print("</tr>");

}





print("<tr></tr><tr></tr>");

print("<tr><td bgcolor=\"#EA947B\">Team Export Old</td></tr>");
print("<tr><td bgcolor=\"#95D096\">Team Export OK</td></tr>");
print("<tr><td><img src=\"checkmark_red.jpg\" border=\"0\"> File Submitted</td></tr>");
print("<tr><td>ST = Spring Training</td></tr>");




print('</table>');





print("</BODY>");
print("</HTML>");
return;

function checkDate($file, $basedir, $leaguefile) {
	//print(filemtime($leaguefile));

	$teamfile = $basedir.$file;
	if (!file_exists($teamfile)) {
		$teamfile = $basedir.strtoupper($file);
	}

	if (file_exists($teamfile) && file_exists($leaguefile)) {
		//print("here1");
		if (filemtime($leaguefile) > filemtime($teamfile)) {
			return true;
		} else {
			//print("here2");
			return false;
		}
	} else {
		//print("here3");
		return true;
	}
}



function getFileDate($file, $basedir) {
	$teamfile = $basedir.$file;
	//print "looking for $teamfile or ";
	if (file_exists($teamfile)) {
		return date("n.d g:ia", filemtime($teamfile));
	}

	$teamfile = $basedir.strtoupper($file);
	//print "$teamfile <br> ";
	if (file_exists($teamfile)) {
		return date("n.d g:ia", filemtime($teamfile));
	} else {
		return 'No File';
	}
}



function getTeamName($file) {
	$file = strtolower($file);
	switch ($file) {
		case 'team1.exp': return 'Philadelphia';
		case 'team2.exp': return 'Ottawa';
		case 'team3.exp': return 'Toronto';
		case 'team4.exp': return 'Montreal';
		case 'team5.exp': return 'New York';
		case 'team6.exp': return 'Seattle';
		case 'team7.exp': return 'Calgary';
		case 'team8.exp': return 'Chicago';
		case 'team9.exp': return 'Los Angeles';
		case 'team10.exp': return 'Vancouver';
		case 'team11.exp': return 'San Juan';
		case 'team12.exp': return 'Atlanta';
		case 'team13.exp': return 'Monterrey';
		case 'team14.exp': return 'Veracruz';
		case 'team15.exp': return 'Havana';
		case 'team16.exp': return 'Tijuana';
		case 'team17.exp': return 'Cancun';
		case 'team18.exp': return 'Mexico City';
		case 'team19.exp': return 'Houston';
		case 'team20.exp': return 'Tampico';
	}
}

function scandir($dirstr) {
   // php.net/scandir (PHP5)
   $files = array();
   $fh = opendir($dirstr);
   while (false !== ($filename = readdir($fh))) {
       array_push($files, $filename);
   }
   closedir($fh);
   return $files;
}



?>

Link to comment
https://forums.phpfreaks.com/topic/38908-php-error/#findComment-187135
Share on other sites

I guess the specific problem relates to this whole section

 

function checkDate($file, $basedir, $leaguefile) {

//print(filemtime($leaguefile));

 

$teamfile = $basedir.$file;

if (!file_exists($teamfile)) {

$teamfile = $basedir.strtoupper($file);

}

 

if (file_exists($teamfile) && file_exists($leaguefile)) {

//print("here1");

if (filemtime($leaguefile) > filemtime($teamfile)) {

return true;

} else {

//print("here2");

return false;

}

} else {

//print("here3");

return true;

}

}

 

--------

 

B/C it says I can not redeclare checkdate?

 

Any ideas...

 

(Whole code is above)

Link to comment
https://forums.phpfreaks.com/topic/38908-php-error/#findComment-187146
Share on other sites

It is because that function (checkdate) is an existing function that comes with PHP. You will need to change the name of that function to something different. Also note function names are case insensitive so using checkDate instead of checkdate are the same. Prehaps use check_date as the functions name instead.

 

The same applies to the scandir function too. You should do something like this instead:

<?php

if(phpversion() < "5.0.0")
    {
        function scandir($dirstr)
        {
           // php.net/scandir (PHP5)
           $files = array();
           $fh = opendir($dirstr);
           while (false !== ($filename = readdir($fh))) {
               array_push($files, $filename);
           }
           closedir($fh);
           return $files;
        }
    }

?>

Link to comment
https://forums.phpfreaks.com/topic/38908-php-error/#findComment-187169
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.