// html output
$tablehead=table_head("show","740","80","left");
$tablefoot=table_foot("show");
$bannerhead=table_head("show","488","80","center");
$bannerfoot=table_foot("show");
$out['title'] = 'Match Tracks Archive';
$out['keywords'] = 'tracks, acmi, tacview, archive, recordings, missions, tcl, team combat league, lock on, lomac' ;
$out['description'] = 'Tracks recordings available from Team Combat League';
// any more content
// <strong><font class='catfont'>Tracks</font></strong><br><hr class='catfont' size='1'>
$out[body]=$out[body]."<center> $bannerhead $out[banner] $bannerfoot <br>
$tablehead
$content
$tablefoot </center>";
include("$dir[curtheme]");
function is_upload_allowed_match($playerid, $matchid) {
if ($playerid <= 0) {
return false;
}
$result = mysql_query("SELECT matchdb.*
FROM matchdb
LEFT JOIN teammembers ON (matchdb.winnerid=teammembers.teamid) OR (matchdb.loserid=teammembers.teamid)
WHERE (matchdb.matchid='$matchid')
AND (teammembers.playerid=$playerid)");
return (mysql_numrows($result) > 0);
}
function get_upload_form_html($playerid, $matchid) {
$result = mysql_query( "SELECT teammembers.teamid, matchdb.*
FROM matchdb
LEFT JOIN teammembers ON (matchdb.winnerid=teammembers.teamid) OR (matchdb.loserid=teammembers.teamid)
WHERE (teammembers.playerid=$playerid)
ORDER BY matchdb.reportdate DESC");
if (mysql_numrows($result) <= 0) {
return 'NoMatches';
}
$script = '<script type="text/javascript">
function setDots(numDots) {
strDots = "";
for (i = 0; i < numDots; i++) {
strDots += ".";
}
document.getElementById("message").innerHTML="Uploading file, please be patient" + strDots;
if (++numDots >5) {
numDots = 1;
}
setTimeout("setDots(" + numDots + ")", 1000);
}
</script>';
$select = '<select name="file_matchid">';
while ($match = mysql_fetch_array($result)) {
$selected = $match['matchid'] == $matchid ? "selected='true'" : "";
$select .= "<option value='$match[matchid]' $selected>$match[winneralias] vs. $match[loseralias] ($match[laddername])</option>";
}
$select .= '</select>';
return $script . '<form enctype="multipart/form-data" action="http://www.teamcombatleague.ca/tracks.php" method="POST">
<input type="hidden" name="action" value="upload_complete">
<table>
<tr>
<td>Select a match:</td><td>' . $select . '</td>
</tr>
<tr>
<td>Choose a file to upload:</td><td><input name="uploadedfile" type="file" title="Maximum file size is 30MB"/></td>
</tr>
<tr>
<td>Give the file a title:</td><td><input name="file_title" type="text" maxlength="40"/></td>
</tr>
<tr>
<td>Description (optional):</td><td><input name="file_desc" type="text" maxlength="500"></td>
</tr>
</table>
<div id="message"></div>
<input type="submit" name="upload_files" onClick=\'setDots(1)\' value="Upload File" />
</form>';
}
function complete_file_upload($playerid) {
$storagedir = STORAGE_DIR;
$currenttime = date("Y-m-d H:i:s");
$extension = strrchr($_FILES['uploadedfile']['name'], '.');
$allowedextentions = '/^\.(txt|acmi|zip|7z|rar|trk)$/i';
if (!preg_match($allowedextentions, $extension)) {
return 'FAIL: BAD_EXTENSION';
}
$filename = md5($currenttime . basename( $_FILES['uploadedfile']['name']));
$savename = $storagedir . $filename;
$matchinfo = array();
$matchid = mysql_real_escape_string(stripslashes($_POST['file_matchid']));
$matches = mysql_query("SELECT matchdb.*
FROM matchdb
LEFT JOIN teammembers ON (matchdb.winnerid=teammembers.teamid) OR (matchdb.loserid=teammembers.teamid)
WHERE (matchdb.matchid='$matchid')
AND (teammembers.playerid=$playerid)");
if (mysql_numrows($matches) <= 0) {
return 'FAIL: NOT_ON_TEAM_OR_NO_SUCH_MATCH';
}
$match = mysql_fetch_array($matches);
$matchinfo = array('wteamid' => $match['winnerid'], 'lteamid' => $match['loserid'], 'id' => $match['matchid'], 'ladderid' => $match['ladderid'], 'matchdate' => $match['reportdate']);
$allowed = "/[^a-z0-9\\040\\-\\_]/i";
$usersetname = preg_replace($allowed, '' ,$_POST['file_title']) . $extension;
if (strlen(trim($usersetname)) <= 0) {
$usersetname = 'noname' . $extension;
}
$description = mysql_real_escape_string(stripslashes($_POST['file_desc']));
if (strlen($description) > 1000) {
$description = substr($description, 0, 1000);
}
// everything is set, complete the upload
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $savename)) {
chmod($savename, 0666);
mysql_query("INSERT INTO tracks VALUES ('', '$matchinfo[id]', '$matchinfo[ladderid]', '$matchinfo[matchdate]', '$playerid', '$matchinfo[wteamid]', '$matchinfo[lteamid]', '$filename', '$usersetname', '$description', '$currenttime')");
return 'SUCCESS!';
} else {
return 'FAIL: ' . $_FILES['uploadedfile']['error'];
}
}
// deletes a file from system, and removes record from database if successful.
function delete_file_id($id) {
$file = mysql_fetch_array(mysql_query("SELECT * FROM tracks WHERE id='$id'"));
if (!$file) {
return 'File not found';
} else {
$file_to_delete = STORAGE_DIR . $file['filename'];
if (unlink($file_to_delete)) {
mysql_query("DELETE FROM tracks WHERE id='$id'");
return 'SUCCESS!';
} else {
return 'File delete failed';
}
}
}
Like I said it works but what does not happen it does not show the next users entry...it should show multiply lines of uploads..