'."\n"); if (!empty($img_url)) { fwrite($res_file, ''); } fwrite($res_file, ''.$img_alt.''); if (!empty($img_url)) { fwrite($res_file, ''); } fwrite($res_file, "\n"); fwrite($res_file, ''."\n"); } function PageHead ($res_file, $page_type, $focus='', $sort_order='') { global $Comp_Annual; global $Comp_Club; global $Comp_Title; global $Comp_Year; fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); $Line=''; if (!empty($Comp_Annual)) { $Line.=$Comp_Annual.' Annual '; } $Line.=$Comp_Title; if (!empty($Comp_Year)) { $Line.=' '.$Comp_Year; } switch ($page_type) { case 'B': $Title='Brewer'; break; case 'E': $Title='Entry Number'; break; case 'G': $Title='Group'; break; default: $Title=''; } fwrite($res_file, $Line.' Results'.($page_type == 'H' ? '' : ' - Score Sheets by '.$Title)."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); } fwrite($res_file, '
'."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); if (img_avail('CLUB')) { Images($res_file, 'CLUB'); } fwrite($res_file, ''."\n"); if (img_avail('COMP')) { Images($res_file, 'COMP'); } fwrite($res_file, ''."\n"); fwrite($res_file, '
'."\n"); $Title=''; if (!empty($Comp_Annual)) { $Title.=$Comp_Annual.' Annual '; } $Title.=$Comp_Title; if (!empty($Comp_Year)) { $Title.=' '.$Comp_Year; } fwrite($res_file, $Title.'
'."\n"); if (!empty($Comp_Club)) { fwrite($res_file, '
Presented by
'."\n"); fwrite($res_file, $Comp_Club.'
'."\n"); } fwrite($res_file, '
'."\n"); $Title='Score Sheets by '; switch ($page_type) { case 'B': $Title.='Brewer'; break; case 'E': $Title.='Entry Number'; break; case 'G': $Title.='Group'; break; } if ($page_type != 'H') { fwrite($res_file, $Title.'

'."\n"); } fwrite($res_file, '
'."\n"); fwrite($res_file, '
'."\n"); $size=2; $class='list'; $border='1'; switch ($page_type) { case 'E': $size=5; $border='0'; break; case 'H': $size=15; $class='menu'; $border='0'; break; } fwrite($res_file, ''."\n"); } function PageFoot ($res_file, $page_type) { if ($page_type != 'H') { fwrite($res_file, '
'."\n"); fwrite($res_file, '
'."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); if ($page_type != 'B') { fwrite($res_file, ''."\n"); } if ($page_type != 'E') { fwrite($res_file, ''."\n"); } if ($page_type != 'G') { fwrite($res_file, ''."\n"); } fwrite($res_file, ''."\n"); fwrite($res_file, '
'); fwrite($res_file, 'Home'); fwrite($res_file, ''); fwrite($res_file, 'Brewers'); fwrite($res_file, ''); fwrite($res_file, 'Entries'); fwrite($res_file, ''); fwrite($res_file, 'Groups'); fwrite($res_file, '
'."\n"); fwrite($res_file, '
'."\n"); fwrite($res_file, ''."\n"); fwrite($res_file, ''."\n"); } function TableHead ($res_file, $page_type, $focus, $sort_order) { $Base=($page_type == 'B' ? 'Brewer' : 'Group'); fwrite($res_file, ''."\n"); if ($page_type == 'G') { fwrite($res_file, ''); fwrite($res_file, 'Group'); fwrite($res_file, ''."\n"); } elseif ($page_type == 'B') { fwrite($res_file, ''); fwrite($res_file, 'Brewer'); fwrite($res_file, ''."\n"); } fwrite($res_file, ''); fwrite($res_file, 'Brewer Name'); fwrite($res_file, ''."\n"); fwrite($res_file, ''); fwrite($res_file, 'Club'); fwrite($res_file, ''."\n"); fwrite($res_file, ''); fwrite($res_file, 'Style'); fwrite($res_file, ''."\n"); fwrite($res_file, ''); fwrite($res_file, 'Place'); fwrite($res_file, ''."\n"); fwrite($res_file, ''); fwrite($res_file, 'Entry'); fwrite($res_file, ''."\n"); fwrite($res_file, ''); fwrite($res_file, 'Score'); fwrite($res_file, ''."\n"); if ($page_type == 'G') { fwrite($res_file, ''); fwrite($res_file, 'Postion'); fwrite($res_file, ''."\n"); } if ($page_type == 'B') { fwrite($res_file, ''); fwrite($res_file, 'Group'); fwrite($res_file, ''."\n"); } fwrite($res_file, ''."\n"); } function BuildPage ($page_type, $focus, $sort_order, $orderby) { global $hbc_name; global $db; $PageName=$hbc_name.'/tmp/'.($page_type == 'G' ? 'Group' : 'Brewer').$focus.($sort_order != 'A' ? 'd' : '').'.html'; echo ($sort_order != 'A' ? '.' : $focus); $page_file=fopen($PageName, 'w+b'); PageHead($page_file, $page_type, $focus, $sort_order); TableHead($page_file, $page_type, $focus, $sort_order); if ($page_type == 'G') { fwrite($page_file, 'BOS'."\n"); for ($lop=1; $lop <= 9; $lop++) { fwrite($page_file, ''."\n"); } } if ($page_type == 'G') { $query='select e.flight, b.brewer_type, b.fullname, b.brewclub, e.cat, e.sub_cat, '; $query.='e.place, e.comp_entry, e.score, e.flight_pos'; } else { $query='select b.brewer, b.brewer_type, b.fullname, b.brewclub, e.cat, e.sub_cat, '; $query.='e.place, e.comp_entry, e.score, e.flight'; } $query.=' from names b, entry e where b.brewer=e.brewer and e.comp_entry is not null order by '.$orderby; $page_res=mysqli_query($db, $query); $hold_val=''; while ($page_row = mysqli_fetch_assoc($page_res)) { fwrite($page_file, '=1 && $page_row['place'] <= 4) ? 'class="place'.$page_row['place'].'"' : '').'>'."\n"); if ($page_type == 'G') { fwrite($page_file, ''); if ($hold_val != $page_row['flight']) { fwrite($page_file, ''.$page_row['flight'].''); $hold_val=$page_row['flight']; } else { fwrite($page_file, ' '); } fwrite($page_file, ''."\n"); } elseif ($page_type == 'B') { $hide_it=$focus == 'B' && $hold_val == $page_row['brewer']; fwrite($page_file, ''); if ($hold_val != $page_row['brewer']) { fwrite($page_file, ''.$page_row['brewer'].''); $hold_val=$page_row['brewer']; } else { fwrite($page_file, ' '); } fwrite($page_file, ''."\n"); } fwrite($page_file, ''); fwrite($page_file, safe($page_row['fullname'])); fwrite($page_file, ''."\n"); fwrite($page_file, ''); fwrite($page_file, ($page_row['brewclub'] != 'None' ? safe($page_row['brewclub']) : ' ')); fwrite($page_file, ''."\n"); fwrite($page_file, ''); fwrite($page_file, $page_row['cat'].$page_row['sub_cat']); fwrite($page_file, ''."\n"); fwrite($page_file, '= 1 && $page_row['place'] <= 4) ? '' : ' class="nb"').'>'); if ($page_row['place'] == 4) { fwrite($page_file, 'HM'); } elseif ($page_row['place'] >= 1 && $page_row['place'] <= 3) { fwrite($page_file, $page_row['place']); } else { fwrite($page_file, ' '); } fwrite($page_file, ''."\n"); fwrite($page_file, ''); fwrite($page_file, ''.$page_row['comp_entry'].''); fwrite($page_file, ''."\n"); fwrite($page_file, ''); fwrite($page_file, $page_row['score']); fwrite($page_file, ''."\n"); if ($page_type == 'G') { fwrite($page_file, ''); fwrite($page_file, $page_row['flight_pos']); fwrite($page_file, ''."\n"); } if ($page_type == 'B') { fwrite($page_file, ''); fwrite($page_file, ''.$page_row['flight'].''); fwrite($page_file, ''."\n"); } fwrite($page_file, ''."\n"); } PageFoot($page_file, $page_type); fclose($page_file); } ?>

Building CD Pages


'."\n"; $EntryName=$hbc_name.'/tmp/Entry.html'; $entry_file=fopen($EntryName, 'w+b'); PageHead($entry_file , 'E'); fwrite($entry_file, ''."\n"); $query='select comp_entry from entry where removed != "Y" and comp_entry is not null order by comp_entry'; $entry_res=mysqli_query($db, $query); $CNT=0; while ($entry_row=mysqli_fetch_assoc($entry_res)) { if ($CNT == 10) { fwrite($entry_file, ''."\n"); fwrite($entry_file, ''."\n"); $CNT=0; } fwrite($entry_file, 'Entry '.$entry_row['comp_entry'].''."\n"); ++$CNT; } while ($CNT < 10) { fwrite($entry_file, ''."\n"); ++$CNT; } fwrite($entry_file, ''."\n"); PageFoot($entry_file, 'E'); fclose($entry_file); echo '
'."\n"; // Group-Flight Pages echo 'Generating Group Pages
'."\n"; $PageG=''; foreach (array('G', 'N', 'C', 'S', 'P', 'E', 'SC', 'FP') as $Value) { switch ($Value) { case 'G': $order='e.flight, e.flight_pos, e.comp_entry'; break; case 'N': $order='e.flight, b.fullname, e.comp_entry'; break; case 'C': $order='e.flight, b.brewclub, e.comp_entry'; break; case 'S': $order='e.flight, e.cat, e.sub_cat, e.comp_entry'; break; case 'P': $order='e.flight, e.place, e.comp_entry'; break; case 'E': $order='e.flight, e.comp_entry'; break; case 'SC': $order='e.flight, e.score, e.comp_entry'; break; case 'FP': $order='e.flight, e.flight_pos, e.comp_entry'; break; } BuildPage ('G', $Value, 'A', $order); $PageG.='Group'.$Value.'.html '; switch ($Value) { case 'G': $order='e.flight desc, e.flight_pos, e.comp_entry'; break; case 'N': $order='e.flight, b.fullname desc, e.comp_entry'; break; case 'C': $order='e.flight, b.brewclub desc, e.comp_entry'; break; case 'S': $order='e.flight, e.cat desc, e.sub_cat desc, e.comp_entry'; break; case 'P': $order='e.flight, e.place desc, e.comp_entry'; break; case 'E': $order='e.flight, e.comp_entry desc'; break; case 'SC': $order='e.flight, e.score desc, e.comp_entry'; break; case 'FP': $order='e.flight, e.flight_pos desc, e.comp_entry'; break; } BuildPage ('G', $Value, 'D', $order); $PageG.='Group'.$Value.'d.html '; } echo '

'."\n"; // Brewer Pages echo 'Generating Brewer Pages
'."\n"; $PageB=''; foreach (array('B', 'F', 'L', 'C', 'S', 'P', 'E', 'SC') as $Value) { switch ($Value) { case 'B': $order='b.brewer, e.comp_entry'; break; case 'N': $order='b.fullname, e.comp_entry'; break; case 'C': $order='b.brewclub, e.brewer, e.comp_entry'; break; case 'S': $order='e.cat, e.sub_cat, e.brewer, e.comp_entry'; break; case 'P': $order='e.place, e.brewer, e.comp_entry'; break; case 'E': $order='e.comp_entry'; break; case 'SC': $order='e.score, e.brewer, e.comp_entry'; break; } BuildPage ('B', $Value, 'A', $order); $PageB.='Brewer'.$Value.'.html '; switch ($Value) { case 'B': $order='b.brewer desc, e.comp_entry'; break; case 'N': $order='b.fullname desc, e.comp_entry'; break; case 'C': $order='b.brewclub desc, e.brewer, e.comp_entry'; break; case 'S': $order='e.cat desc, e.sub_cat desc, e.brewer, e.comp_entry'; break; case 'P': $order='e.place desc, e.brewer, e.comp_entry'; break; case 'E': $order='e.comp_entry desc'; break; case 'SC': $order='e.score desc, e.brewer, e.comp_entry'; break; } BuildPage ('B', $Value, 'D', $order); $PageB.='Brewer'.$Value.'d.html '; } echo '

'."\n"; // Home-Main Page $HomeName=$hbc_name.'/tmp/index.html'; echo 'Generating Home/Main Page
'."\n"; $home_file=fopen($HomeName, 'w+b'); PageHead($home_file , 'H'); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ' '."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, 'Competition Results'."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, 'Score Sheets by Entry Number'."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, 'Score Sheets by Brewer'."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, 'Score Sheets by Group'."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, 'Style Guidelines'."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ' '."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, 'Get Adobe Reader 9.1.0'."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); fwrite($home_file, ''."\n"); PageFoot($home_file, 'H'); fclose($home_file); echo '

'."\n"; //Create zipped tar file $BaseDir=$_SERVER['DOCUMENT_ROOT'].'/'.$hbc_name; $TarFile='CD_Pages.tgz'; $TarCmd='tar --create --dir '.$BaseDir.'/tmp --file '.$BaseDir.'/'.$TarFile.' --gzip '; $TarCmd.=$PageB.' Entry.html '.$PageG.' index.html'; shell_exec ($TarCmd); // CleanUp @unlink($BaseDir.'/tmp/Entry.html'); foreach (array('G', 'N', 'C', 'S', 'P', 'E', 'SC', 'FP') as $Value) { @unlink($BaseDir.'/tmp/Group'.$Value.'.html'); @unlink($BaseDir.'/tmp/Group'.$Value.'d.html'); } foreach (array('B', 'N', 'C', 'S', 'P', 'E', 'SC') as $Value) { @unlink($BaseDir.'/tmp/Brewer'.$Value.'.html'); @unlink($BaseDir.'/tmp/Brewer'.$Value.'d.html'); } @unlink($BaseDir.'/tmp/index.html'); // Provide Download Prompt echo ''."\n"; echo 'Download CD Pages'."\n"; echo ''."\n"; ?>