Skip to content

Commit

Permalink
Fix Loader Issues; Winner Display
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Humphrey committed Feb 1, 2019
1 parent b07b94e commit 8e8da22
Show file tree
Hide file tree
Showing 18 changed files with 1,118 additions and 1,008 deletions.
2 changes: 1 addition & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Website: http://www.brewcompetition.com
GitHub: https://github.com/geoffhumphrey/brewcompetitiononlineentry
SourceForge: http://sourceforge.net/projects/brewcompetition [Archives ONLY]

Release 2.1.15, 2019-01-09
Release 2.1.16, 2019-02-01

Developed utilizing a number of extensions and functions, with gratitude to their
respective developers and online communities. Tested with the following versions:
Expand Down
2 changes: 1 addition & 1 deletion admin/default.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@
<div class="col col-lg-8 col-md-8 col-sm-8 col-xs-8">
<ul class="list-inline">
<li><a id="modal_window_link" class="hide-loader" href="<?php echo $base_url; ?>output/print.output.php?section=staff&amp;go=judging_assignments&amp;action=download&amp;filter=default&amp;view=default" data-toggle="tooltip" data-placement="top" title="Print the BJCP Points report for judges, stewards, and staff">Print</a></li>
<li><a href="<?php echo $base_url; ?>output/export.output.php?section=staff&amp;go=judging_assignments&amp;action=download&amp;filter=default&amp;view=pdf" data-toggle="tooltip" data-placement="top" title="Download a PDF of the BJCP points report for judges, stewards, and staff">PDF</a></li>
<li><a class="hide-loader" href="<?php echo $base_url; ?>output/export.output.php?section=staff&amp;go=judging_assignments&amp;action=download&amp;filter=default&amp;view=pdf" data-toggle="tooltip" data-placement="top" title="Download a PDF of the BJCP points report for judges, stewards, and staff">PDF</a></li>
<?php if (empty($_SESSION['contestID'])) { ?>
<li><a href="#" data-toggle="modal" data-target="#BJCPCompIDModal">XML</a></li>
<?php } else { ?>
Expand Down
6 changes: 3 additions & 3 deletions admin/entries.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
$entry_actions .= "</a> ";
$entry_actions .= "<a class=\"hide-loader\" href=\"".$base_url."includes/process.inc.php?section=".$section."&amp;go=".$go."&amp;filter=".$filter."&amp;dbTable=".$brewing_db_table."&amp;action=delete&amp;id=".$row_log['id']."\" data-toggle=\"tooltip\" title=\"Delete &ldquo;".$row_log['brewName']."&rdquo;\" data-confirm=\"Are you sure you want to delete the entry called &ldquo;".$row_log['brewName']."?&rdquo; This cannot be undone.\"><span class=\"fa fa-lg fa-trash-o\"></a> ";
$entry_actions .= "<a id=\"modal_window_link\" class=\"hide-loader\" href=\"".$base_url."output/entry.output.php?id=".$row_log['id']."&amp;bid=".$brewer_info[7]."&amp;filter=admin\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Print the Entry Forms for &ldquo;".$row_log['brewName']."&rdquo;\"><span class=\"fa fa-lg fa-print hidden-xs hidden-sm\"></a> ";
$entry_actions .= "<a href=\"mailto:".$brewer_info[6]."\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Email the entry&rsquo;s owner, ".$brewer_info[0]." ".$brewer_info[1].", at ".$brewer_info[6]."\"><span class=\"fa fa-lg fa-envelope\"></span></a> ";
$entry_actions .= "<a class=\"hide-loader\" href=\"mailto:".$brewer_info[6]."\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Email the entry&rsquo;s owner, ".$brewer_info[0]." ".$brewer_info[1].", at ".$brewer_info[6]."\"><span class=\"fa fa-lg fa-envelope\"></span></a> ";
}

$scoresheet_link_1 = "";
Expand All @@ -286,7 +286,7 @@
$scoresheet_random_file_relative_1 = "user_temp/".$random_file_name_1;
$scoresheet_random_file_1 = USER_TEMP.$random_file_name_1;
$scoresheet_random_file_html_1 = $base_url.$scoresheet_random_file_relative_1;
$scoresheet_link_1 .= "<a href=\"".$base_url."output/scoresheets.output.php?";
$scoresheet_link_1 .= "<a class=\"hide-loader\" href=\"".$base_url."output/scoresheets.output.php?";

// Obfuscate the *ACTUAL* file names.
// Prevents casual users from right clicking on scoresheet download link and changing
Expand Down Expand Up @@ -321,7 +321,7 @@
$scoresheet_random_file_2 = USER_TEMP.$random_file_name_2;
$scoresheet_random_file_html_2 = $base_url.$scoresheet_random_file_relative_2;

$scoresheet_link_2 .= "<a href=\"".$base_url."output/scoresheets.output.php?";
$scoresheet_link_2 .= "<a class=\"hide-loader\" href=\"".$base_url."output/scoresheets.output.php?";

// Obfuscate the *ACTUAL* file names.
// Prevents casual users from right clicking on scoresheet download link and changing
Expand Down
128 changes: 120 additions & 8 deletions admin/judging_scores.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,8 @@
$table_score_data = table_score_data($row_scores['eid'],$row_scores['scoreTable'],$filter);
$table_score_data = explode("^",$table_score_data);

if ((NHC) && ($prefix == "final_")) $entry_number = sprintf("%06s",$table_score_data[0]);
else $entry_number = sprintf("%04s",$table_score_data[0]);

if ((NHC) || ($_SESSION['prefsEntryForm'] == "N")) $judging_number = sprintf("%06s",$table_score_data[6]);
else $judging_number = readable_judging_number($table_score_data[1],$table_score_data[6]);
$entry_number = sprintf("%04s",$table_score_data[0]);
$judging_number = sprintf("%06s",$table_score_data[6]);

if ($row_scores['scorePlace'] == "5") $score_place = "HM";
elseif ($row_scores['scorePlace'] == "6") $score_place = "Admin Advance";
Expand All @@ -205,6 +202,123 @@
else $entry_category = $table_score_data[12].": ".$table_score_data[1];
}

// Check whether scoresheet file exists, and, if so, provide link.
$scoresheet_file_name_entry = sprintf("%06s",$entry_number).".pdf";
$scoresheet_file_name_judging = $judging_number.".pdf"; // upon upload via the UI, filename is converted to lowercase

if ($dbTable == "default") {
$scoresheetfile_entry = USER_DOCS.$scoresheet_file_name_entry;
$scoresheetfile_judging = USER_DOCS.$scoresheet_file_name_judging;
$scoresheet_prefs = $_SESSION['prefsDisplaySpecial'];
}

else {
$scoresheetfile_entry = USER_DOCS.DIRECTORY_SEPARATOR.get_suffix($dbTable).DIRECTORY_SEPARATOR.$scoresheet_file_name_entry;
$scoresheetfile_judging = USER_DOCS.DIRECTORY_SEPARATOR.get_suffix($dbTable).DIRECTORY_SEPARATOR.$scoresheet_file_name_judging;
$scoresheet_prefs = $row_archive_prefs['archiveScoresheet'];
}

$scoresheet = FALSE;
$scoresheet_entry = FALSE;
$scoresheet_judging = FALSE;

if ((file_exists($scoresheetfile_entry)) && ($scoresheet_prefs == "E")) {
$scoresheet = TRUE;
$scoresheet_entry = TRUE;
}

elseif ((file_exists($scoresheetfile_judging)) && ($scoresheet_prefs == "J")) {
$scoresheet = TRUE;
$scoresheet_judging = TRUE;
}

$scoresheet_file_name_1 = "";
$scoresheet_file_name_2 = "";
$scoresheet_link_1 = "";
$scoresheet_link_2 = "";

if ($scoresheet_entry) $scoresheet_file_name_1 = $scoresheet_file_name_entry;
if ($scoresheet_judging) $scoresheet_file_name_2 = $scoresheet_file_name_judging;

if (($scoresheet) && ($action != "print")) {

if ((!empty($scoresheet_file_name_1)) && ($scoresheet_entry)) {

// The pseudo-random number and the corresponding name of the temporary file are defined each time
// this brewer_entries.sec.php script is accessed (or refreshed), but the temporary file is created
// only when the entrant clicks on the gavel icon to access the scoresheet.
$random_num_str_1 = random_generator(8,2);
$random_file_name_1 = $random_num_str_1.".pdf";
$scoresheet_random_file_relative_1 = "user_temp/".$random_file_name_1;
$scoresheet_random_file_1 = USER_TEMP.$random_file_name_1;
$scoresheet_random_file_html_1 = $base_url.$scoresheet_random_file_relative_1;
$scoresheet_link_1 .= "<a class=\"hide-loader\" href=\"".$base_url."output/scoresheets.output.php?";

// Obfuscate the *ACTUAL* file names.
// Prevents casual users from right clicking on scoresheet download link and changing
// the entry or judging number pdf name passed via the URL to force downloads of files
// they shouldn't have access to. Can I get a harumph?!

/*
if (function_exists('openssl_encrypt')) {
$scoresheet_link_1 .= "scoresheetfilename=".obfuscateURL($scoresheet_file_name_1);
$scoresheet_link_1 .= "&amp;randomfilename=".obfuscateURL($random_file_name_1)."&amp;download=true";
}
*/


$scoresheet_link_1 .= "scoresheetfilename=".urlencode(obfuscateURL($scoresheet_file_name_1,$encryption_key));
$scoresheet_link_1 .= "&amp;randomfilename=".urlencode(obfuscateURL($random_file_name_1,$encryption_key))."&amp;download=true";

if ($dbTable != "default") $scoresheet_link_1 .= "&amp;view=".get_suffix($dbTable);
$scoresheet_link_1 .= sprintf("\" data-toggle=\"tooltip\" title=\"%s '".$table_score_data[3]."'' (by Entry Number).\">",$brewer_entries_text_006);
$scoresheet_link_1 .= "<span class=\"fa fa-lg fa-gavel\"></a>&nbsp;&nbsp;";
}

if ((!empty($scoresheet_file_name_2)) && ($scoresheet_judging)) {

// The pseudo-random number and the corresponding name of the temporary file are defined each time
// this brewer_entries.sec.php script is accessed (or refreshed), but the temporary file is created
// only when the entrant clicks on the gavel icon to access the scoresheet.

$random_num_str_2 = random_generator(8,2);
$random_file_name_2 = $random_num_str_2.".pdf";
$scoresheet_random_file_relative_2 = "user_temp/".$random_file_name_2;
$scoresheet_random_file_2 = USER_TEMP.$random_file_name_2;
$scoresheet_random_file_html_2 = $base_url.$scoresheet_random_file_relative_2;

$scoresheet_link_2 .= "<a class=\"hide-loader\" href=\"".$base_url."output/scoresheets.output.php?";

// Obfuscate the *ACTUAL* file names.
// Prevents casual users from right clicking on scoresheet download link and changing
// the entry or judging number pdf name passed via the URL to force downloads of files
// they shouldn't have access to. Can I get a harumph?!
$scoresheet_link_2 .= "scoresheetfilename=".urlencode(obfuscateURL($scoresheet_file_name_2,$encryption_key));
$scoresheet_link_2 .= "&amp;randomfilename=".urlencode(obfuscateURL($random_file_name_2,$encryption_key))."&amp;download=true";
if ($dbTable != "default") $scoresheet_link_2 .= "&amp;view=".get_suffix($dbTable);
$scoresheet_link_2 .= sprintf("\" data-toggle=\"tooltip\" title=\"%s '".$table_score_data[3]."' (by Judging Number).\">",$brewer_entries_text_006);
$scoresheet_link_2 .= "<span class=\"fa fa-lg fa-gavel\"></a>&nbsp;&nbsp;";
}

// Clean up temporary scoresheets created for other brewers, when they are at least 1 minute old (just to avoid problems when two entrants try accessing their scoresheets at practically the same time, and clean up previously created scoresheets for the same brewer, regardless of how old they are.
$tempfiles = array_diff(scandir(USER_TEMP), array('..', '.'));

if (is_array($tempfiles)) {
foreach ($tempfiles as $file) {
if ((filectime(USER_TEMP.$file) < time() - 1*60) || ((strpos($file, $scoresheet_file_name_judging) !== FALSE))) {
unlink(USER_TEMP.$file);
}

if ((filectime(USER_TEMP.$file) < time() - 1*60) || ((strpos($file, $scoresheet_file_name_entry) !== FALSE))) {
unlink(USER_TEMP.$file);
}
}
}

if ((($dbTable == "default") && ($_SESSION['prefsDisplaySpecial'] == "E")) || ($dbTable != "default")) $entry_actions = $scoresheet_link_1;
if ((($dbTable == "default") && ($_SESSION['prefsDisplaySpecial'] == "J")) || ($dbTable != "default")) $entry_actions = $scoresheet_link_2;
}

?>
<tr>
<td><?php echo $entry_number; ?></td>
Expand All @@ -221,9 +335,7 @@
<td><?php echo $score_place; ?></td>
<td><?php echo $mini_bos; ?></td>
<?php if ($dbTable == "default") { ?>
<td><a href="<?php echo $base_url; ?>index.php?section=admin&amp;go=<?php echo $go; ?>&amp;action=edit&amp;id=<?php echo $table_score_data[9]; ?>" data-toggle="tooltip" data-placement="top" title="Edit the <?php echo $table_score_data[10]; ?> scores"><span class="fa fa-lg fa-pencil"></span></a>
<a class="hide-loader" href="<?php echo $base_url; ?>includes/process.inc.php?action=delete&amp;go=<?php echo $go; ?>&amp;id=<?php echo $row_scores['id']; ?>" data-toggle="tooltip" data-placement="top" title="Delete this score for entry #<?php echo $row_scores['eid']; ?>" data-confirm="Are you sure? This will delete the score and/or place for this entry."><span class="fa fa-lg fa-trash-o"></span></a>
</td>
<td><a href="<?php echo $base_url; ?>index.php?section=admin&amp;go=<?php echo $go; ?>&amp;action=edit&amp;id=<?php echo $table_score_data[9]; ?>" data-toggle="tooltip" data-placement="top" title="Edit the <?php echo $table_score_data[10]; ?> scores"><span class="fa fa-lg fa-pencil"></span></a>&nbsp;<?php echo $entry_actions; ?>&nbsp;<a class="hide-loader" href="<?php echo $base_url; ?>includes/process.inc.php?action=delete&amp;go=<?php echo $go; ?>&amp;id=<?php echo $row_scores['id']; ?>" data-toggle="tooltip" data-placement="top" title="Delete this score for entry #<?php echo $row_scores['eid']; ?>" data-confirm="Are you sure? This will delete the score and/or place for this entry."><span class="fa fa-lg fa-trash-o"></span></a></td>
<?php } ?>
</tr>
<?php
Expand Down
8 changes: 4 additions & 4 deletions admin/participants.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,18 +253,18 @@
if ($row_brewer['brewerEmail'] != $_SESSION['loginUsername']) $output_datatables_other_link = build_action_link("fa-lock",$base_url,"admin","make_admin","default","default",$row_brewer['uid'],"default","default",0,"Change ".$brewer_tooltip_display_name."&rsquo;s User Level");
else $output_datatables_other_link = "<span class=\"fa fa-lg fa-lock text-muted\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"You cannot change your own user level, ".$_SESSION['brewerFirstName'].".\"></span>";
if (strpos($brewer_assignment,'Judge') !== false) {
$output_datatables_view_link = "<a href=\"".$base_url."output/labels.output.php?section=admin&amp;go=participants&amp;action=judging_labels&amp;id=".$row_brewer['id']."&amp;psort=5160\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Download Judge Scoresheet Labels for ".$brewer_tooltip_display_name." - Letter (Avery 5160)\"><span class=\"fa fa-lg fa-file\"></span></a> <a href=\"".$base_url."output/labels.output.php?section=admin&amp;go=participants&amp;action=judging_labels&amp;id=".$row_brewer['id']."&amp;psort=3422\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Download Judge Scoresheet Labels for ".$brewer_tooltip_display_name." - A4 (Avery 3422)\"><span class=\"fa fa-lg fa-file-text\"></span></a>";
$output_datatables_view_link = "<a class=\"hide-loader\" href=\"".$base_url."output/labels.output.php?section=admin&amp;go=participants&amp;action=judging_labels&amp;id=".$row_brewer['id']."&amp;psort=5160\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Download Judge Scoresheet Labels for ".$brewer_tooltip_display_name." - Letter (Avery 5160)\"><span class=\"fa fa-lg fa-file\"></span></a> <a class=\"hide-loader\" href=\"".$base_url."output/labels.output.php?section=admin&amp;go=participants&amp;action=judging_labels&amp;id=".$row_brewer['id']."&amp;psort=3422\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Download Judge Scoresheet Labels for ".$brewer_tooltip_display_name." - A4 (Avery 3422)\"><span class=\"fa fa-lg fa-file-text\"></span></a>";
}
else $output_datatables_view_link = "";
$output_datatables_other_link2 = build_action_link("fa-user",$base_url,"user","default","username","admin",$row_brewer['uid'],"default","default",0,"Change ".$brewer_tooltip_display_name."&rsquo;s email address");
$output_datatables_email_link .= "<a href=\"mailto:".$row_brewer['brewerEmail']."\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Email ".$brewer_tooltip_display_name." at ".$row_brewer['brewerEmail']."\"><span class=\"fa fa-lg fa-envelope\"></span></a>";
$output_datatables_email_link .= "<a class=\"hide-loader\" href=\"mailto:".$row_brewer['brewerEmail']."\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"Email ".$brewer_tooltip_display_name." at ".$row_brewer['brewerEmail']."\"><span class=\"fa fa-lg fa-envelope\"></span></a>";

if ($us_phone) {
$output_datatables_phone_link = "<a href=\"#\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"".$brewer_tooltip_display_name."&rsquo;s phone number: ".format_phone_us($row_brewer['brewerPhone1'])."\"><span class=\"fa fa-lg fa-phone\"></span></a>";
$output_datatables_phone_link = "<a class=\"hide-loader\" href=\"#\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"".$brewer_tooltip_display_name."&rsquo;s phone number: ".format_phone_us($row_brewer['brewerPhone1'])."\"><span class=\"fa fa-lg fa-phone\"></span></a>";
}

else {
$output_datatables_phone_link = "<a href=\"#\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"".$brewer_tooltip_display_name."&rsquo;s phone number: ".$row_brewer['brewerPhone1']."\"><span class=\"fa fa-lg fa-phone\"></span></a>";
$output_datatables_phone_link = "<a class=\"hide-loader\" href=\"#\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"".$brewer_tooltip_display_name."&rsquo;s phone number: ".$row_brewer['brewerPhone1']."\"><span class=\"fa fa-lg fa-phone\"></span></a>";
}

$output_datatables_user_question_link = "<a href=\"#\" data-tooltip=\"true\" data-toggle=\"modal\" data-target=\"#user-question-modal-".$row_brewer['uid']."\" data-placement=\"top\" title=\"Click to see ".$brewer_tooltip_display_name."&rsquo;s secret question and answer\"><span class=\"fa fa-lg fa-question-circle\"></span></a>";
Expand Down
2 changes: 1 addition & 1 deletion admin/upload.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
while ($file = readdir($handle)) {
if(!is_dir($file) && !is_link($file)) {
$filelist .= "<tr>\n";
$filelist .= "<td><a class=\"user_images\" rel=\"group1\" href=\"".$base_url."user_images/$file\" title=\"".$file."\" >".$file."</a></td>\n";
$filelist .= "<td><a class=\"user_images hide-loader\" rel=\"group1\" href=\"".$base_url."user_images/$file\" title=\"".$file."\" >".$file."</a></td>\n";
$filelist .= "<td>".date("l, F j, Y H:i", filemtime($upload_dir.$file))."</td>\n";
$filelist .= "<td><a class=\"hide-loader\" href=\"".$base_url."includes/process.inc.php?action=delete&amp;go=image&amp;filter=".$file."&amp;view=".$action."\" data-confirm=\"Are you sure? This will remove the image named ".$file." from the server.\"><span class=\"fa fa-lg fa-trash\"></span></a></td>\n";
$filelist .= "</tr>\n";
Expand Down
2 changes: 1 addition & 1 deletion admin/upload_scoresheets.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
$scoresheet_random_file = USER_TEMP.$random_file_name;
$scoresheet_random_file_html = $base_url.$scoresheet_random_file_relative;
$scoresheet_link = "";
$scoresheet_link .= "<a href=\"".$base_url."output/scoresheets.output.php?";
$scoresheet_link .= "<a class=\"hide-loader\" href=\"".$base_url."output/scoresheets.output.php?";
$scoresheet_link .= "scoresheetfilename=".urlencode(obfuscateURL($scoresheet_file_name,$encryption_key));
$scoresheet_link .= "&amp;randomfilename=".urlencode(obfuscateURL($random_file_name,$encryption_key))."&amp;download=true";
$scoresheet_link .= "\">".$scoresheet_file_name."</a>";
Expand Down
6 changes: 3 additions & 3 deletions includes/current_version.inc.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
// For storage in DB and update script use
$current_version = "2.1.15.0";
$current_version = "2.1.16.0";

// For on-screen display and consistency
$current_version_display = "2.1.15";
$current_version_display = "2.1.16";

// Add if pre-release - alpha, beta, etc., otherwise leave empty
$current_version_display_append = "";
if (!empty($current_version_display_append)) $current_version_display .= " ".$current_version_display_append;

// Change date for each pre-release and release. Will trigger a force update.
$current_version_date_display = "2019-01-09";
$current_version_date_display = "2019-02-01";

// Convert current version date to Unix timestamp
$current_version_date = strtotime($current_version_date_display);
Expand Down
Loading

0 comments on commit 8e8da22

Please sign in to comment.