Esempio n. 1
0
function show_page()
{
    lmt_page_header('Undelete');
    echo <<<HEREDOC
      <h1><span class="dontMess">**</span>Undelete</h1>
      
      <h3>Individuals</h3>

HEREDOC;
    $result = DB::queryRaw('SELECT id, name FROM individuals WHERE deleted="1"');
    $row = mysqli_fetch_assoc($result);
    while ($row) {
        echo '      <a href="Undelete?Individual=' . htmlentities($row['id']) . '">' . htmlentities($row['name']) . '</a><br />' . "\n";
        $row = mysqli_fetch_assoc($result);
    }
    echo "\n      <h3>Teams</h3>\n";
    $result = DB::queryRaw('SELECT team_id, name FROM teams WHERE deleted="1"');
    $row = mysqli_fetch_assoc($result);
    while ($row) {
        echo '      <a href="Undelete?Team=' . htmlentities($row['team_id']) . '">' . htmlentities($row['name']) . '</a><br />' . "\n";
        $row = mysqli_fetch_assoc($result);
    }
    echo "\n      <h3>Schools</h3>\n";
    $result = DB::queryRaw('SELECT school_id, name FROM schools WHERE deleted="1"');
    $row = mysqli_fetch_assoc($result);
    while ($row) {
        echo '      <a href="Undelete?School=' . htmlentities($row['school_id']) . '">' . htmlentities($row['name']) . '</a><br />' . "\n";
        $row = mysqli_fetch_assoc($result);
    }
}
Esempio n. 2
0
function show_page()
{
    global $javascript;
    $javascript = <<<HEREDOC
      window.onbeforeunload = function (evt) {
        return "If you navigate away from this page, you will have to re-select your teams!";
      }
HEREDOC;
    lmt_page_header('Guts Round');
    echo <<<HEREDOC
      <h1>Guts Round</h1>
      
      <table id="gutsTable">
        <tr>
          <td><object class="gutsFrame" data="Embed" type="text/html"></object></td>
          <td><object class="gutsFrame" data="Embed" type="text/html"></object></td>
        </tr><tr>
          <td><object class="gutsFrame" data="Embed" type="text/html"></object></td>
          <td><object class="gutsFrame" data="Embed" type="text/html"></object></td>
        </tr><tr>
          <td><object class="gutsFrame" data="Embed" type="text/html"></object></td>
          <td><object class="gutsFrame" data="Embed" type="text/html"></object></td>
        </tr>
      </table>
HEREDOC;
}
Esempio n. 3
0
function show_page($err)
{
    lmt_page_header('Refrigerator');
    if (scoring_is_enabled()) {
        $scoring_status = 'Enabled';
        $scoring_action = 'lmt_freeze_scoring';
        $scoring_action_name = 'Freeze';
    } else {
        $scoring_status = 'Frozen';
        $scoring_action = 'lmt_enable_scoring';
        $scoring_action_name = 'Enable';
    }
    echo <<<HEREDOC
      <h1><span class="dontMess">*</span>Refrigerator</h1>
      
      <div class="text-centered">
        <span class="b red">WARNING: The only person who should use this page is the Scoring Czar!</span>
        <div class="halfbreak"></div>
        Before printing results, disable score entry using this feature.
        <div class="halfbreak"></div>
        If you need to re-enable scoring, first destroy all printed copies of the results list,<br />
        and make sure to re-freeze scoring and refresh your browser before viewing it again!
        <br /><br />
        <form method="post" action="{$_SERVER['REQUEST_URI']}"><div>
          <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" />
          <input type="submit" name="{$scoring_action}" value="{$scoring_action_name}" />
        </div></form>
      </div>
HEREDOC;
    die;
}
Esempio n. 4
0
function show_page()
{
    global $body_onload;
    $body_onload = 'document.forms[\'lmtSearchAll\'].Query.focus()';
    global $jquery_function;
    $jquery_function = <<<HEREDOC
      //<![CDATA[
      \$.widget( "custom.catcomplete", \$.ui.autocomplete, {
        _renderMenu: function( ul, items ) {
          var self = this,
          currentCategory = "";
          \$.each( items, function( index, item ) {
            if ( item.category != currentCategory ) {
              ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
              currentCategory = item.category;
            }
            self._renderItem( ul, item );
          });
        }
      });
      \$(function() {
        \$( "#autocomplete" ).catcomplete({
          source: "../Autocomplete?School&Team&Individual"
        });
      });
      //]]>
HEREDOC;
    lmt_page_header('Data Home');
    echo <<<HEREDOC
      <h1>Data Home</h1>
      
      <div class="text-centered b">WARNING: Please be careful when changing information through the Data pages.
      When in doubt (or if you think you might have messed something up), ask the Tech Czar.</div>
      
      <h3>Search</h3>
      <form id="lmtSearchAll" method="get" action="../Search"><div>
        <input type="text" id="autocomplete" name="Query" size="35" />
        <input type="hidden" name="Scope" value="School Team Individual" />
        <input type="hidden" name="From" value="Data Home" />
        <input type="hidden" name="Return" value="Data" />
        <input type="submit" value="Search" />
      </div></form>
      
      <h3>View Data</h3>
      <table class="contrasting">
        <tr><td><a href="List?Schools">Schools &amp; Coaches</a></td></tr>
        <tr><td><a href="List?Teams">Teams</a></td></tr>
        <tr><td><a href="List?Individuals">All Individuals</a></td></tr>
        <tr><td><a href="List?Unaffiliated">Unaffiliated Individuals</a></td></tr>
      </table>
      
      <h3 class="smbottom">Add</h3>
      <span class="small b" style="color: #d00;">(Can cause major problems. Ask the Tech Czar first, really!)</span>
      <div class="halfbreak"></div>
      ...<a href="Add?School">a School</a><br />
      ...<a href="Add?Team">a Team</a><br />
      ...<a href="Add?Individual">an Individual</a><br />
      ...<a href="Undelete">Undelete</a>
HEREDOC;
}
Esempio n. 5
0
function show_page()
{
    $row = DB::queryFirstRow('SELECT * FROM pages WHERE page_id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '"');
    $name = htmlentities($row['name']);
    $content = "      " . str_replace("\n", "\n      ", $row['content']);
    if (strpos($content, '<h1>') != 6) {
        $content = '<h1></h1><br /><br />' . $content;
    }
    global $LMT_EMAIL;
    $content = str_replace('{CONTACT_LINK}', email_obfuscate($LMT_EMAIL, null, '<span class="b">Please email us at:</span> '), $content);
    $page_id = htmlentities($_GET['ID']);
    global $use_rel_external_script;
    $use_rel_external_script = true;
    lmt_page_header($name);
    echo <<<HEREDOC
\t  <div style="float: left; margin-top: 40px;">
        <a href="List"><img src="../../../res/icons/arrow_left.png" alt="" /> Return to Page List</a>
        <div class="halfbreak"></div>
        <a href="Edit?ID={$page_id}"><img src="../../../res/icons/edit.png" alt="" /></a>
        <a href="Delete?ID={$page_id}"><img src="../../../res/icons/delete.png" alt="" /></a>
      </div>
      

HEREDOC;
    echo $content;
}
Esempio n. 6
0
function show_page()
{
    // If the Registration page does not exist, add it
    if (DB::queryFirstField('SELECT COUNT(*) FROM pages WHERE page_id="-1"') == 0) {
        $new_order_num = DB::queryFirstField('SELECT (MIN(order_num) - 1) AS new_order FROM pages');
        DB::insert('pages', array('page_id' => '-1', 'name' => 'Registration', 'content' => '', 'order_num' => $new_order_num));
    }
    lmt_page_header('Page List');
    $delete_alert = fetch_alert('deletePage');
    echo <<<HEREDOC
      <h1>Page List</h1>
      {$delete_alert}
      <a href="Add"><img src="../../../res/icons/add.png" alt="+" /> Add a Page</a><br />
      <a href="Add_Separator?xsrf_token={$_SESSION['xsrf_token']}"><img src="../../../res/icons/add.png" alt="+" /> Add a Separator</a><br />
      <br />
      <h4 class="smbottom">Pages</h4>
HEREDOC;
    $table = lmt_db_table('SELECT page_id, name, order_num FROM pages ORDER BY order_num', array('name' => ''), array('<img src="../../../res/icons/eye.png" alt="View" />' => 'View?ID={page_id}', '<img src="../../../res/icons/edit.png" alt="Edit" />' => 'Edit?ID={page_id}', '<img src="../../../res/icons/delete.png" alt="Delete" />' => 'Delete?ID={page_id}'), 'No Pages', 'contrasting indented', array('page' => 'Order', 'field' => 'page_id'));
    //Make the Separators come out nicely
    $search = '#<td></td>(\\s+)<td><a href="View\\?ID=(\\d+)"><img src="../../../res/icons/eye.png" alt="View" /></a></td>(\\s+)<td><a href="Edit\\?ID=(\\d+)"><img src="../../../res/icons/edit.png" alt="Edit" /></a></td>(\\s+)<td><a href="Delete\\?ID=(\\d+)"><img src="../../../res/icons/delete.png" alt="Delete" /></a></td>(\\s+)</tr>#';
    $replace = '<td>[Separator]</td>${1}<td></td>${1}<td></td>${1}<td><a href="Delete_Separator?ID=${2}&amp;xsrf_token=' . $_SESSION['xsrf_token'] . '"><img src="../../../res/icons/delete.png" alt="Delete" /></a></td>${1}</tr>';
    $table = preg_replace($search, $replace, $table);
    // Make Registration uneditable
    $search = '#<td><a href="View\\?ID=-1"><img src="../../../res/icons/eye.png" alt="View" /></a></td>(\\s+)<td><a href="Edit\\?ID=-1"><img src="../../../res/icons/edit.png" alt="Edit" /></a></td>(\\s+)<td><a href="Delete\\?ID=-1"><img src="../../../res/icons/delete.png" alt="Delete" /></a></td>(\\s+)</tr>#';
    $replace = '<td></td>${1}<td></td>${1}<td></td>${1}</tr>';
    $table = preg_replace($search, $replace, $table);
    echo $table;
}
Esempio n. 7
0
function show_form()
{
    lmt_page_header('Pre-LMT');
    ?>
	<h1>Pre-LMT</h1>
	<p>This page is for preparing things before each LMT. If you're not an admin, you <b>should not be here</b>. 
  <b>If you are an admin, please follow <i>every</i> step on this page.</b></p>
<?php 
    die;
}
Esempio n. 8
0
function lmt_custom_errors($errno, $errstr, $errfile, $errline)
{
    $rh = fopen(PATH::errfile(), 'a+');
    fwrite($rh, date(DATE_RFC822) . ' Error [' . $errno . '] on line ' . $errline . ' in ' . $errfile . ': ' . $errstr . "\n");
    fclose($rh);
    global $miniature_page;
    if (isset($miniature_page)) {
        $miniature_page = '?Mini';
    }
    if (headers_sent()) {
        echo '<meta http-equiv="refresh" content="0;url=' . URL::root() . '/LMT/Error' . $miniature_page . '">';
    } else {
        if (isset($_GET['xsrf_token'])) {
            header('Location: ' . URL::root() . '/LMT/Error' . $miniature_page);
        } else {
            if (isset($miniature_page)) {
                $urlroot = URL::root();
                echo <<<HEREDOC
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title></title>
    <link rel="stylesheet" href="{$urlroot}/res/default.css" type="text/css" media="all" />
    <link rel="stylesheet" href="{$urlroot}/res/lmt.css" type="text/css" media="all" />
    <link rel="stylesheet" href="{$urlroot}/res/print.css" type="text/css" media="print" />
  </head>
  
  <body class="gutsEmbedSetup">
    <div style="width: 350px; height: 30px; background-color: #fd0; margin: -10px;"></div>
    <br />
    <br />
    <div class="text-centered b">
      An error occurred.
      <div class="halfbreak"></div>
      (<a href="{$_SERVER['REQUEST_URI']}">reload</a>)
    </div>
  </body>
</html>
HEREDOC;
            } else {
                header("HTTP/1.1 500 Internal Server Error");
                lmt_page_header('Error');
                echo <<<HEREDOC
      <h1>Error</h1>
      
      Whoops! Something went wrong. Try again?
HEREDOC;
            }
        }
    }
    die;
}
Esempio n. 9
0
function show_page()
{
    lmt_page_header('Email');
    echo <<<HEREDOC
      <h1>Email</h1>
      
      <div class="registration-box">
        <a href="Coaches">Email Coaches</a>
        <a href="Individuals">Email Individuals</a>
      </div>
HEREDOC;
}
Esempio n. 10
0
function show_page()
{
    lmt_page_header('Guts Round');
    echo <<<HEREDOC
      <h1>Guts Round</h1>
      
      <div class="registration-box">
        <a href="Enter_Scores">Enter Scores</a>
        <a href="Display/Home">Guts Display</a>
\t\t<a href="Extra" class="box-light">Extra</a>
      </div>
HEREDOC;
}
Esempio n. 11
0
function preview_message()
{
    if (!validate_message()) {
        return;
    }
    global $subject, $bb_body, $body, $email, $EMAIL_ADDRESS, $LMT_EMAIL;
    // Get info for the byline
    $query = 'SELECT name, email FROM users WHERE id="' . $_SESSION['user_id'] . '"';
    $result = DB::queryRaw($query);
    $row = mysqli_fetch_assoc($result);
    $disp_subject = '[LMT ' . htmlentities(map_value('year')) . '] ' . $subject;
    lmt_page_header('Email Coaches');
    echo <<<HEREDOC
      <h1>Email Coaches</h1>
      
      <table class="spacious">
        <tr>
          <td>From:</td>
          <td><span class="b">LMT Mailbot &lt;{$EMAIL_ADDRESS}&gt;</span></td>
        </tr><tr>
          <td>Reply To:&nbsp;</td>
          <td><span class="b">{$LMT_EMAIL}</span><br /></td>
        </tr><tr>
          <td>Subject:</td>
          <td><span class="b">{$disp_subject}</span><br /><br /></td>
        </tr><tr>
          <td>Body:</td>
          <td>{$bb_body}<br /><br /></td>
        </tr><tr>
          <td></td>
          <td>
            <form id="composeMessage" method="post" action="{$_SERVER['REQUEST_URI']}"><div>
              <input type="hidden" name="subject" value="{$subject}" />
              <input type="hidden" name="body" value="{$body}" />
              <input type="hidden" name="email" value="{$email}" />
              <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" />
              <input type="submit" name="lmtc_do_reedit_message" value="Back to Editing" />
              <input type="submit" name="lmtc_do_post_message" value="Send Message" />
            </div></form>
          </td>
        </tr><tr>
          <td></td>
          <td><span class="small">Please do not click the &quot;Send Message&quot; button twice!</span></td>
        </tr>
      </table>
      

HEREDOC;
}
Esempio n. 12
0
function show_frozen_page()
{
    if (scoring_is_enabled()) {
        trigger_error('Error: Scoring is enabled!', E_USER_ERROR);
    }
    lmt_page_header('Scoring Frozen');
    echo <<<HEREDOC
      <h1>Scoring Frozen</h1>
      
      <div class="text-centered b">Scoring has been frozen so that results
      may be tabulated. If some results have not yet been entered or are incorrect,
      please see the Head Grader immediately!</div>
HEREDOC;
    die;
}
Esempio n. 13
0
function do_signout()
{
    session_destroy();
    unset($_SESSION);
    session_start();
    lmt_page_header('Signed Out');
    echo <<<HEREDOC
      <h1>Signed Out</h1>
      
      <div class="text-centered">
        You have been signed out. You may continue to add or modify teams until<br />
        registration closes through the link in the confirmation email.
      </div>
HEREDOC;
}
Esempio n. 14
0
function show_form($err)
{
    global $use_rel_external_script;
    $use_rel_external_script = true;
    lmt_page_header('Edit Page');
    if ($err != '') {
        $err = "\n        <div class=\"error\">{$err}</div><br />\n";
    }
    @($name = htmlentities($_POST['name']));
    @($content = htmlentities($_POST['content']));
    // Fetch data if this is the first time the form has been shown
    if ($name == '' || $content == '') {
        $row = DB::queryFirstRow('SELECT name, content FROM pages WHERE page_id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '"');
        if ($name == '') {
            $name = htmlentities($row['name']);
        }
        if ($content == '') {
            $content = htmlentities($row['content']);
        }
    }
    echo <<<HEREDOC
      <h1>Edit Page</h1>
      {$err}
      <form id="lmtAddPage" method="post" action="{$_SERVER['REQUEST_URI']}">
        <table class="spacious">
          <tr>
            <td>Title:</td>
            <td><input type="text" name="name" value="{$name}" size="25" maxlength="25" /></td>
          </tr><tr>
            <td>Content:&nbsp;</td>
            <td>
              <textarea name="content" rows="25" cols="80" class="code">{$content}</textarea>
              <div class="small">Please write XHTML-compliant code.<br />
              Links marked with rel=&quot;external&quot; open in a new window. Links are relative to /LMT.</div><br />
            </td>
          </tr><tr>
            <td></td>
            <td>
              <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" />
              <input type="submit" name="lmt_do_edit_page" value="Save Changes" />
              &nbsp;&nbsp;<a href="List">Cancel</a><br /><br /><br />
            </td>
          </tr>
        </table>
      </form>
HEREDOC;
    die;
}
Esempio n. 15
0
function show_page()
{
    global $meta_refresh;
    $meta_refresh = '900; URL=Backup';
    lmt_page_header('Backup');
    echo <<<HEREDOC
      <h1>Backup</h1>
      
      <div class="text-centered b">
        This page will generate a database backup and refresh every 15 minutes.
      </div>
      
      <iframe src="Backup?Download" style="display: none;">
      </iframe>
HEREDOC;
}
Esempio n. 16
0
function show_page()
{
    lmt_page_header('Guts Extra');
    echo <<<HEREDOC
      <h1>Guts Extra</h1>
      
      <span class="b">Average x:</span> 
HEREDOC;
    $c_sub = "SELECT (SELECT AVG(guts_ans_c) FROM teams WHERE deleted=\"0\") as avg";
    $row = DB::queryFirstRow($c_sub);
    $avg = $row['avg'];
    if ($avg == '' || is_null($avg)) {
        $avg = '0';
    }
    echo $avg;
}
Esempio n. 17
0
function show_page()
{
    global $header_noprint;
    $header_noprint = true;
    lmt_page_header('Attendance Sheets');
    echo <<<HEREDOC
      <h1 class="noPrint">Attendance Sheets</h1>
      
      <div class="text-centered b noPrint">To generate attendance sheets for the coaches, please print<br />
      this page single-sided in portrait mode at normal size.</div>
      
      <div class="printOnly">

HEREDOC;
    $result = DB::queryRaw('SELECT team_id, teams.name AS team_name, teams.school AS school_id,' . ' schools.name AS school_name FROM teams LEFT JOIN schools' . ' ON teams.school=schools.school_id WHERE teams.deleted="0" ORDER BY school_name, team_name');
    $row = mysqli_fetch_assoc($result);
    while ($row) {
        $team_id = htmlentities($row['team_id']);
        $team_name = htmlentities($row['team_name']);
        $school = htmlentities($row['school_name']);
        if ($school == '') {
            $school = 'None';
        }
        echo <<<HEREDOC
\t\t<h2 style="float: right;">{$team_id}</h2>
        <h1 style="text-align: left; margin: 0;">{$team_name}</h1>
        <h3 class="i noMargin">{$school}</h3>
        <br /><br />
HEREDOC;
        $result2 = DB::queryRaw('SELECT name FROM individuals WHERE team="' . mysqli_real_escape_string(DB::get(), $team_id) . '" AND deleted="0" ORDER BY name');
        $row2 = mysqli_fetch_assoc($result2);
        if (!$row2) {
            echo "\n" . '        <h3 class="text-centered">No Members</span>' . "\n\n";
        }
        while ($row2) {
            $name = htmlentities($row2['name']);
            echo "\n" . '        <div class="attendPerson"><div class="checkBox"></div>' . $name . '</div>';
            $row2 = mysqli_fetch_assoc($result2);
        }
        echo "\n" . '        <div class="pageBreak"></div>' . "\n\n";
        $row = mysqli_fetch_assoc($result);
    }
    echo "      </div>";
}
Esempio n. 18
0
function show_logged_in_page()
{
    //If there's no such school, we're in the middle of adding it or something.
    if (DB::queryFirstField('SELECT COUNT(*) FROM teams WHERE school=%i', $_SESSION['LMT_user_id']) == 0) {
        header('Location: Team?Add');
        die;
    }
    lmt_page_header('Team Registration');
    $lmt_year = htmlentities(map_value('year'));
    $school_name = htmlentities($_SESSION['LMT_school_name']);
    $table = lmt_db_table('SELECT team_id, name, school, (SELECT COUNT(*) FROM individuals WHERE individuals.team = teams.team_id AND individuals.deleted="0")' . ' AS size FROM teams WHERE school="' . mysqli_real_escape_string(DB::get(), $_SESSION['LMT_user_id']) . '" AND deleted="0" ORDER BY size, name', array('name' => 'Name', 'size' => 'Size'), array('<img src="../../res/icons/edit.png" alt="Edit" />' => 'Team?Edit={team_id}', '<img src="../../res/icons/delete.png" alt="Delete" />' => 'Team?Delete={team_id}'), 'No Teams', 'contrasting indented');
    echo <<<HEREDOC
      <h1>Team Registration</h1>
      
      <h3 class="smbottom">Teams for {$school_name}</h3>
      <span class="small">&nbsp;<a href="Team?Add">Add a Team</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="Signout">Sign Out</a></span><br /><br />
      {$table}
HEREDOC;
}
Esempio n. 19
0
function show_page()
{
    global $use_rel_external_script;
    $use_rel_external_script = true;
    lmt_page_header('Validation');
    echo <<<HEREDOC
      <h1>Verify Database</h1>
      <div class="text-centered b">
        <span>
          <a href="#basic">Basic Information</a>&nbsp;&nbsp;
          <a href="#checkin">Checkin</a>&nbsp;&nbsp;
          <a href="#grading">Grading</a>&nbsp;&nbsp;
          <a href="#guts">Guts</a>
          <br /><br />
        </span>
      </div>
      
HEREDOC;
    echo do_verify();
}
Esempio n. 20
0
function show_page()
{
    lmt_page_header('Score Entry');
    echo <<<HEREDOC
      <h1>Score Entry</h1>
      
      <div class="registration-box">
        <a href="Individual">Individual Round</a>
        <a href="Theme">Theme Round</a>
      </div>
      
      <div class="registration-box">
        <a href="Team_Short">Team Round: Short Answer</a>
        <a href="Team_Long">Team Round: Long Answer</a>
      </div>
      
      <div class="registration-box">
        <a href="Refrigerator" class="box-light">Scoring Control</a>
        <a href="Verification" class="box-light">Verification</a>
      </div>
HEREDOC;
}
Esempio n. 21
0
function show_form($err)
{
    global $body_onload, $use_rel_external_script;
    $body_onload = 'document.forms[\'lmtAddPage\'].name.focus();externalLinks();';
    $use_rel_external_script = true;
    lmt_page_header('Add Page');
    if ($err != '') {
        $err = "\n        <div class=\"error\">{$err}</div><br />\n";
    }
    $name = htmlentities($_POST['name']);
    $content = htmlentities($_POST['content']);
    echo <<<HEREDOC
      <h1>Add Page</h1>
      {$err}
      <form id="lmtAddPage" method="post" action="{$_SERVER['REQUEST_URI']}">
        <table class="spacious">
          <tr>
            <td>Title:</td>
            <td><input type="text" name="name" value="{$name}" size="25" maxlength="25" /></td>
          </tr><tr>
            <td>Content:&nbsp;</td>
            <td>
              <textarea name="content" rows="25" cols="80" class="code">{$content}</textarea>
              <div class="small">Please write XHTML-compliant code.<br />
              Links marked with rel=&quot;external&quot; open in a new window. Links are relative to /LMT.</div><br />
            </td>
          </tr><tr>
            <td></td>
            <td>
              <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" />
              <input type="submit" name="lmt_do_add_page" value="Add Page" />
              &nbsp;&nbsp;<a href="List">Cancel</a><br /><br /><br />
            </td>
          </tr>
        </table>
      </form>
HEREDOC;
    die;
}
Esempio n. 22
0
function show_page()
{
    $name = str_replace('_', ' ', $_GET['Name']);
    //Why?
    if ($name == "Register") {
        header("Location: Registration");
        die;
    }
    $content = DB::queryFirstField('SELECT content FROM pages WHERE name=%s', $name);
    if (!$content) {
        header("HTTP/1.1 404 Not Found");
        require 'Error.php';
        die;
    }
    $name = htmlentities($name);
    $content = "      " . str_replace("\n", "\n      ", $content);
    global $LMT_EMAIL;
    $content = str_replace('{CONTACT_LINK}', email_obfuscate($LMT_EMAIL, null, '<span class="b">Please email us at:</span> '), $content);
    global $use_rel_external_script;
    $use_rel_external_script = true;
    lmt_page_header($name);
    echo $content;
}
Esempio n. 23
0
function show_page()
{
    $row = DB::queryFirstRow('SELECT * FROM pages WHERE page_id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '"');
    $name = htmlentities($row['name']);
    $content = "      " . str_replace("\n", "\n      ", $row['content']);
    lmt_page_header('Delete Page');
    echo <<<HEREDOC
      <h1>Delete Page</h1>
      
      <span class="b">Are you sure that you want to delete this page?</span>
      <div class="halfbreak"></div>
      <form method="post" action="{$_SERVER['REQUEST_URI']}"><div>
        <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" />
        <input type="submit" name="lmt_do_delete_page" value="Delete" />
        &nbsp;&nbsp;<a href="List">Cancel</a>
      </div></form>
      
      <br /><hr />
      

HEREDOC;
    echo $content;
}
Esempio n. 24
0
function show_multiple_results_page()
{
    lmt_page_header('Score Entry');
    $name = htmlentities($_POST['name']);
    $result = DB::queryRaw('SELECT id, individuals.name AS name, grade, teams.name AS team_name, ' . '(SELECT name FROM schools WHERE schools.school_id=teams.school) AS school_name ' . 'FROM individuals LEFT JOIN teams ON individuals.team=teams.team_id WHERE individuals.name="' . mysqli_real_escape_string(DB::get(), $_POST['name']) . '" AND teams.deleted="0"');
    echo <<<HEREDOC
      <h1>Theme Round Score Entry</h1>
      
      <div class="text-centered">
        Multiple individuals named <span class="b">{$name}</span> exist. Please select the correct one:
      </div>
      <br />
      
      <table class="contrasting table-center">
        <tr>
          <th>Name</th>
          <th>Grade</th>
          <th>Team</th>
          <th>School</th>
        </tr>

HEREDOC;
    $score = htmlentities($_POST['score']);
    $row = mysqli_fetch_assoc($result);
    while ($row) {
        $id = htmlentities($row['id']);
        $name = htmlentities($row['name']);
        $grade = htmlentities($row['grade']);
        $team = htmlentities($row['team_name']);
        $school = htmlentities($row['school_name']);
        echo <<<HEREDOC
        <tr>
          <td><a href="Theme?ID={$id}&amp;Score={$score}&amp;xsrf_token={$_SESSION['xsrf_token']}">{$name}</a></td>
          <td>{$grade}</td>
          <td>{$team}</td>
          <td>{$school}</td>
        </tr>

HEREDOC;
        $row = mysqli_fetch_assoc($result);
    }
    echo <<<HEREDOC
      </table>
      
      <a href="Theme">&larr; Cancel</a>
HEREDOC;
    die;
}
Esempio n. 25
0
function show_page()
{
    if (scoring_is_enabled()) {
        $message = '<div class="error">Score entry is still enabled! Disable it <a href="../Scoring/Refrigerator">here</a>.</div><br />';
    }
    lmt_page_header('Top Scorers');
    echo <<<HEREDOC
      <h1>Top Scorers</h1>
      {$message}
      <div class="text-centered b">
        <span class="noPrint">
          <a href="Full">Full Results</a>&nbsp;&nbsp;
          <a href="Print">Scores for Coaches</a>
          <br /><br />
        </span>
        <span class="red">Reminder: Do not copy data locally!</span><br />
        Ties are listed in random order.
        <br /><br />
      </div>
      
      <h2>Top 5 Individuals by Individual Round</h2>
      <table class="contrasting">
        <tr>
          <th>Place</th>
          <th>Name</th>
          <th>School</th>
          <th>Individual Round</th>
        </tr>
HEREDOC;
    score_guts();
    // INDIVIDUAL ROUND
    $query = 'SELECT id, individuals.name AS name, (SELECT name FROM schools WHERE school_id=teams.school) AS school_name, ' . 'RAND() AS rand, score_individual FROM individuals LEFT JOIN teams ON team=teams.team_id WHERE individuals.deleted="0" AND attendance="1" ORDER BY score_individual DESC, rand';
    $result = DB::queryRaw($query);
    $row = mysqli_fetch_assoc($result);
    $place = 0;
    $num = 0;
    $last_score = null;
    while ($row) {
        $num++;
        if ($row['score_individual'] != $last_score) {
            $place = $num;
        }
        $last_score = $row['score_individual'];
        if ($place > 5) {
            break;
        }
        $id = htmlentities($row['id']);
        $name = htmlentities($row['name']);
        $school = htmlentities($row['school_name']);
        if ($school == '') {
            $school = '<span class="i">None</span>';
        }
        $score_individual = htmlentities($row['score_individual']);
        echo <<<HEREDOC
        <tr>
          <td>{$place}</td>
          <td><a href="../Data/Individual?ID={$id}">{$name}</a></td>
          <td>{$school}</td>
          <td class="b">{$score_individual}</td>
        </tr>
HEREDOC;
        $row = mysqli_fetch_assoc($result);
    }
    echo "      </table>\n";
    // Theme ROUND
    echo <<<HEREDOC
      <h2>Top 5 Individuals by Theme Round</h2>
      <table class="contrasting">
        <tr>
          <th>Place</th>
          <th>Name</th>
          <th>School</th>
          <th>Theme Round</th>
        </tr>
HEREDOC;
    $query = 'SELECT id, individuals.name AS name, (SELECT name FROM schools WHERE school_id=teams.school) AS school_name, ' . 'RAND() AS rand, score_theme FROM individuals LEFT JOIN teams ON team=teams.team_id WHERE individuals.deleted="0" AND attendance="1" ORDER BY score_theme DESC, rand';
    $result = DB::queryRaw($query);
    $row = mysqli_fetch_assoc($result);
    $place = 0;
    $num = 0;
    $last_score = null;
    while ($row) {
        $num++;
        if ($row['score_theme'] != $last_score) {
            $place = $num;
        }
        $last_score = $row['score_theme'];
        if ($place > 5) {
            break;
        }
        $id = htmlentities($row['id']);
        $name = htmlentities($row['name']);
        $school = htmlentities($row['school_name']);
        if ($school == '') {
            $school = '<span class="i">None</span>';
        }
        $score_theme = htmlentities($row['score_theme']);
        echo <<<HEREDOC
        <tr>
          <td>{$place}</td>
          <td><a href="../Data/Individual?ID={$id}">{$name}</a></td>
          <td>{$school}</td>
          <td class="b">{$score_theme}</td>
        </tr>
HEREDOC;
        $row = mysqli_fetch_assoc($result);
    }
    echo "      </table>\n";
    // INDIVIDUAL COMPOSITE
    echo <<<HEREDOC
      <h2>Top 10 Individuals by Composite</h2>
      <table class="contrasting">
        <tr>
          <th>Place</th>
          <th>Name</th>
          <th>School</th>
          <th>Composite</th>
        </tr>
HEREDOC;
    $query = individual_composite('id, individuals.name AS name, (SELECT name FROM schools WHERE school_id=teams.school) AS school_name, ' . 'RAND() AS rand,', 'LEFT JOIN teams ON team=teams.team_id WHERE individuals.deleted="0" AND attendance="1" ORDER BY score_composite DESC, rand');
    $result = DB::queryRaw($query);
    $row = mysqli_fetch_assoc($result);
    $place = 0;
    $num = 0;
    $last_score = null;
    while ($row) {
        $num++;
        if ($row['score_composite'] != $last_score) {
            $place = $num;
        }
        $last_score = $row['score_composite'];
        if ($place > 10) {
            break;
        }
        $id = htmlentities($row['id']);
        $name = htmlentities($row['name']);
        $school = htmlentities($row['school_name']);
        if ($school == '') {
            $school = '<span class="i">None</span>';
        }
        $score_composite = htmlentities($row['score_composite']);
        echo <<<HEREDOC
        <tr>
          <td>{$place}</td>
          <td><a href="../Data/Individual?ID={$id}">{$name}</a></td>
          <td>{$school}</td>
          <td class="b">{$score_composite}</td>
        </tr>
HEREDOC;
        $row = mysqli_fetch_assoc($result);
    }
    echo "      </table>\n";
    // TEAM ROUND
    echo <<<HEREDOC
      <h2>Top 5 Teams by Team Round</h2>
      <table class="contrasting">
        <tr>
          <th>Place</th>
          <th>Team Name</th>
          <th>Team Round</th>
        </tr>
HEREDOC;
    $query = 'SELECT team_id, name, IFNULL(score_team_short, 0) + IFNULL(score_team_long, 0) AS score_team, RAND() AS rand FROM teams WHERE deleted="0" ORDER BY score_team DESC, rand';
    $result = DB::queryRaw($query);
    $row = mysqli_fetch_assoc($result);
    $place = 0;
    $num = 0;
    $last_score = null;
    while ($row) {
        $num++;
        if ($row['score_team'] != $last_score) {
            $place = $num;
        }
        $last_score = $row['score_team'];
        if ($place > 5) {
            break;
        }
        $id = htmlentities($row['team_id']);
        $name = htmlentities($row['name']);
        $score_team = htmlentities($row['score_team']);
        if (is_null($row['score_team'])) {
            $score_team = '<span class="i">None</span>';
        }
        echo <<<HEREDOC
        <tr>
          <td>{$place}</td>
          <td><a href="../Data/Team?ID={$id}">{$name}</a></td>
          <td class="b">{$score_team}</td>
        </tr>
HEREDOC;
        $row = mysqli_fetch_assoc($result);
    }
    echo "      </table>\n";
    // GUTS ROUND
    echo <<<HEREDOC
      <h2>Top 5 Teams by Guts Round</h2>
      <table class="contrasting">
        <tr>
          <th>Place</th>
          <th>Team Name</th>
          <th>Guts Round</th>
        </tr>
HEREDOC;
    $query = 'SELECT team_id, name, score_guts, RAND() AS rand FROM teams WHERE deleted="0" ORDER BY score_guts DESC, rand';
    $result = DB::queryRaw($query);
    $row = mysqli_fetch_assoc($result);
    $place = 0;
    $num = 0;
    $last_score = null;
    while ($row) {
        $num++;
        if ($row['score_guts'] != $last_score) {
            $place = $num;
        }
        $last_score = $row['score_guts'];
        if ($place > 5) {
            break;
        }
        $id = htmlentities($row['team_id']);
        $name = htmlentities($row['name']);
        $score_guts = htmlentities($row['score_guts']);
        if (is_null($row['score_guts'])) {
            $score_guts = '<span class="i">None</span>';
        }
        echo <<<HEREDOC
        <tr>
          <td>{$place}</td>
          <td><a href="../Data/Team?ID={$id}">{$name}</a></td>
          <td class="b">{$score_guts}</td>
        </tr>
HEREDOC;
        $row = mysqli_fetch_assoc($result);
    }
    echo "      </table>\n";
    // TEAM COMPOSITE
    echo <<<HEREDOC
      <h2>Top 5 Teams by Composite</h2>
      <table class="contrasting">
        <tr>
          <th>Place</th>
          <th>Team Name</th>
          <th>Team Round</th>
          <th>Guts Round</th>
          <th>Composite</th>
        </tr>
HEREDOC;
    $query = team_composite('team_id, name, IFNULL(score_team_short, 0) + IFNULL(score_team_long, 0) AS score_team, score_guts, RAND() AS rand,', 'WHERE deleted="0" ORDER BY team_composite DESC, rand');
    $result = DB::queryRaw($query);
    $row = mysqli_fetch_assoc($result);
    $place = 0;
    $num = 0;
    $last_score = null;
    while ($row) {
        $num++;
        if ($row['team_composite'] != $last_score) {
            $place = $num;
        }
        $last_score = $row['team_composite'];
        if ($place > 5) {
            break;
        }
        $id = htmlentities($row['team_id']);
        $name = htmlentities($row['name']);
        $score_team = htmlentities($row['score_team']);
        $score_guts = htmlentities($row['score_guts']);
        $score_composite = htmlentities($row['team_composite']);
        if (is_null($row['score_team'])) {
            $score_team = '<span class="i">None</span>';
        }
        if (is_null($row['score_guts'])) {
            $score_guts = '<span class="i">None</span>';
        }
        echo <<<HEREDOC
        <tr>
          <td>{$place}</td>
          <td><a href="../Data/Team?ID={$id}">{$name}</a></td>
          <td>{$score_team}</td>
          <td>{$score_guts}</td>
          <td class="b">{$score_composite}</td>
        </tr>
HEREDOC;
        $row = mysqli_fetch_assoc($result);
    }
    echo "      </table>\n";
    die;
}
Esempio n. 26
0
function show_page($err)
{
    global $javascript;
    $javascript = <<<HEREDOC
      function nullboxSetState(isClick) {
        if (document.forms['gutsFull'].aHasValue.checked) {
          document.forms['gutsFull'].a.disabled = false;
          if (isClick == 1)
            document.forms['gutsFull'].a.focus();
        }
        else
          document.forms['gutsFull'].a.disabled = true;
        
        if (document.forms['gutsFull'].bHasValue.checked) {
          document.forms['gutsFull'].b.disabled = false;
          if (isClick == 2)
            document.forms['gutsFull'].b.focus();
        }
        else
          document.forms['gutsFull'].b.disabled = true;
        
        if (document.forms['gutsFull'].cHasValue.checked) {
          document.forms['gutsFull'].c.disabled = false;
          if (isClick == 3)
            document.forms['gutsFull'].c.focus();
        }
        else
          document.forms['gutsFull'].c.disabled = true;
      }
HEREDOC;
    global $body_onload;
    $body_onload = 'nullboxSetState(-1);';
    lmt_page_header('Guts Round');
    $row = DB::queryFirstRow('SELECT name, guts_ans_a, guts_ans_b, guts_ans_c, ' . '(SELECT name FROM schools WHERE schools.school_id=teams.school) AS school_name ' . 'FROM teams WHERE team_id="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '"');
    $team_name = htmlentities($row['name']);
    $school_name = htmlentities($row['school_name']);
    $a = $row['guts_ans_a'];
    $b = $row['guts_ans_b'];
    $c = $row['guts_ans_c'];
    if (is_null($a)) {
        $a = '';
        $a_checked = '';
    } else {
        $a = htmlentities($a);
        $a_checked = ' checked="checked"';
    }
    if (is_null($b)) {
        $b = '';
        $b_checked = '';
    } else {
        $b = htmlentities($b);
        $b_checked = ' checked="checked"';
        $b_hidden = $b;
    }
    if (is_null($c)) {
        $c = '';
        $c_checked = '';
    } else {
        $c = htmlentities($c);
        $c_checked = ' checked="checked"';
    }
    $result = DB::queryRaw('SELECT problem_set, score FROM guts WHERE team="' . mysqli_real_escape_string(DB::get(), $_GET['ID']) . '" ORDER BY problem_set');
    $selected = array();
    for ($i = 1; $i < 12; $i++) {
        $selected[$i] = array('', '', '', '');
    }
    $row = mysqli_fetch_assoc($result);
    while ($row) {
        if (isset($row['score'])) {
            $selected[$row['problem_set']][$row['score']] = ' selected="selected"';
            $scores[$row['problem_set']] = htmlentities($row['score']);
        }
        $row = mysqli_fetch_assoc($result);
    }
    $table = '';
    for ($set = 1; $set < 12; $set++) {
        $problems = 3 * $set - 2 . ' to ' . 3 * $set;
        if (isset($scores[$set])) {
            $value = $scores[$set];
        } else {
            $value = 'None';
        }
        if (!isset($selected[$set])) {
            $none_selected = ' selected="selected"';
        } else {
            $none_selected = '';
        }
        $table .= <<<HEREDOC
        <tr>
          <td>{$set}</td>
          <td>{$problems}</td>
          <td>
            <select name="{$set}" class="text-centered">
              <option value="None"{$none_selected}>None</option>
              <option value="0"{$selected[$set][0]}>0</option>
              <option value="1"{$selected[$set][1]}>1</option>
              <option value="2"{$selected[$set][2]}>2</option>
              <option value="3"{$selected[$set][3]}>3</option>
            </select>
          </td>
          <td>
            <input type="hidden" name="previous_value_{$set}" value="{$value}" />
            <input type="submit" name="guts_full_update_{$set}" value="Update" />
          </td>
        </tr>
HEREDOC;
        //$row = $next_row;
    }
    if ($err != '') {
        $err = "\n        <div class=\"error\">{$err}</div><br />\n";
    }
    $alert = fetch_alert('gutsFull');
    echo <<<HEREDOC
      <h1>Guts Round</h1>
      
      <div class="text-centered">
        Note that only one set may be changed at a time. When you are done making changes, please
        double-check that all scores are entered as intended. Note that invalid answers to the last
        three problems will be treated as no answer. Lastly, do not use the enter key on this page.
      </div>
      <br /><br />
      
      {$err}{$alert}
      <h3 class="noMargin">{$team_name}</h3>
      <div class="halfbreak"></div>
      <span class="i">{$school_name}</span><br />
      <br />
      
      <form id="gutsFull" method="post" action="{$_SERVER['REQUEST_URI']}"><div>
      <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" />
      
      <table class="contrasting text-centered">
        <tr>
          <th>Set</th>
          <th>Problems</th>
          <th>Score/Answer</th>
          <th></th>
        </tr>
{$table}
        <tr>
          <td></td>
          <td>34</td>
          <td>
            <input type="checkbox" name="aHasValue" value="Yes" onchange="nullboxSetState(1);"{$a_checked} />
            <input type="text" name="a" size="10" maxlength="100" value="{$a}" />
          </td>
          <td><input type="submit" name="guts_full_update_a" value="Update" /></td>
        </tr>
        <tr>
          <td style="background-color: #f7fcff;">12</td>
          <td>35</td>
          <td>
            <input type="checkbox" name="bHasValue" value="Yes" onchange="nullboxSetState(2);"{$b_checked} />
            <input type="text" name="b" size="10" maxlength="100" value="{$b}" />
          </td>
          <td><input type="submit" name="guts_full_update_b" value="Update" /></td>
        </tr>
        <tr>
          <td></td>
          <td>36</td>
          <td>
            <input type="checkbox" name="cHasValue" value="Yes" onchange="nullboxSetState(3);"{$c_checked} />
            <input type="text" name="c" size="10" maxlength="100" value="{$c}" />
          </td>
          <td><input type="submit" name="guts_full_update_c" value="Update" /></td>
        </tr>
      </table></div></form>
HEREDOC;
    die;
}
Esempio n. 27
0
<?php

/*
 * LMT/Backstage/Home.php
 * LHS Math Club Website
 *
 * A landing page for people going Backstage
 */
require_once '../../.lib/lmt-functions.php';
backstage_access();
global $use_rel_external_script;
$use_rel_external_script = true;
lmt_page_header('Backstage');
echo '<h1>Backstage</h1>' . map_value('backstage_message');
Esempio n. 28
0
function show_form()
{
    lmt_page_header('Post-LMT');
    ?>
	<h1>Post-LMT</h1>
	<p>This page is for upgrading things across the LMT website to reflect the next year's information,
  archiving the last year's information, and various other operations. Use this right after every LMT.
  If you're not an admin, you <b>should not be here</b>. 
  <b>If you are an admin, please follow <i>every</i> step on this page.</b></p>
	<br>
	<h3>Before doing this:</h3>
  <ul>
    <li style="color:red">You MUST download a <a href='<?php 
    echo URL::lmt();
    ?>
/Backstage/Database/Backup.php' target='_blank'>backup</a> of the database and upload it to the Dropbox. This script doesn't necessarily work, so you need this to restore everything if it messes up.</li>
    <li>On <a href="<?php 
    echo URL::lmt();
    ?>
/Backstage/Status" target='_blank'>Status</a>, make sure scoring is frozen, registration is closed, and backstage is closed to regular members. Post_LMT will handle the rest.</li>
  </ul>
	<br>
	<form id='upyearform' autocomplete='off' method="POST" onsubmit="return confirm('Are you sure?');" >
    <fieldset>
      <!--To discourage autocomplete-->
      <input type="text" style="display:none">
      <input type="password" style="display:none">
      
      <input type='hidden' name='xsrf_token' value='<?php 
    echo $_SESSION['xsrf_token'];
    ?>
'/>
      <table>
        <tr><td>Webmaster Secret Code (see server config):<td><input type="password" autocomplete='off' name="code" />
        <tr><td>Year upgrading from:<td> <input type="text" name="yrfrom" value="" length=4/><br>
        <tr><td>Year upgrading to:<td> <input type="text" name="yrto" value="" length=4 />
      </table>
      <input type="submit" name="upyear" value="Upgrade Year" />
      <div style='color:#f00'>This is a very complicated operation, and CANNOT be undone (other than restoring from the backup you made, which is unpleasant). Please be careful that you only run this once, and that you enter the correct inputs.</div>
    </fieldset>
	</form>
  <br>
	<h3>After this, you also need to...</h3>
	<ul>
		<li>Change any necessary general information in <a href="Status" target="_blank">Status</a></li>
    <br>
		<li>Verify that the archive page has the right stuff (e.g. if you broke any ties manually, they will not be shown accurately).</li>
		<li>Link the flickr album on the archive page (<a href="<?php 
    echo URL::lmt();
    ?>
/Backstage/Pages/List" target='_blank'>Website</a>)</li>
		<li>Put all problems, solutions, and the full zip file into the LMT Dropbox folder</li>
    <br>
    <li>Send the mass "Thanks for coming to LMT!" email</li>
    <li><a href="<?php 
    echo URL::lmt();
    ?>
/Backstage/Results/Email" target='_blank'>Send all the results emails</a></li>
	</ul>
<?php 
    die;
}
Esempio n. 29
0
function do_search()
{
    if ($_GET['Query'] == '') {
        header('Location: ' . back_link());
        die;
    }
    $result_table = '';
    $url = null;
    $urlbase = 'Data';
    if ($_GET['Return'] == 'Checkin') {
        $urlbase = 'Checkin';
    }
    $scope = ' ' . $_GET['Scope'];
    $return = $_GET['Return'];
    $query = mysqli_real_escape_string(DB::get(), $_GET['Query']);
    $query = str_replace(" ", "%", $query);
    if (strpos($scope, 'Individual') !== false) {
        $result = DB::queryRaw('SELECT individuals.*, teams.name AS team_name,' . ' (SELECT name FROM schools WHERE schools.school_id=teams.school) AS school_name' . ' FROM individuals LEFT JOIN teams ON individuals.team=teams.team_id' . ' WHERE individuals.name LIKE "%' . $query . '%" AND individuals.deleted="0" ORDER BY individuals.name');
        $row = mysqli_fetch_assoc($result);
        $table = false;
        if ($row) {
            $result_table .= <<<HEREDOC
      <h3>Individuals</h3>
      <table class="indented contrasting">
        <tr>
          <th>Name</th>
          <th>Grade</th>
          <th>School</th>
          <th>Team</th>
        </tr>
HEREDOC;
            $table = true;
        }
        while ($row) {
            $label = htmlentities($row['name']);
            $grade = htmlentities($row['grade']);
            $school_name = htmlentities($row['school_name']);
            $team_name = htmlentities($row['team_name']);
            if ($row['team'] == -1) {
                $team_name = '<span class="i">Not Assigned</span>';
                $school_name = '<span class="i">Unaffiliated</span>';
            }
            $url = $urlbase . '/Individual?ID=' . htmlentities($row['id']);
            $result_table .= "        <tr><td><a href=\"{$url}\">{$label}</a></td><td class=\"text-centered\">{$grade}</td><td>{$school_name}</td><td>{$team_name}</td></tr>\n";
            $row = mysqli_fetch_assoc($result);
        }
        if ($table) {
            $result_table .= "      </table>\n";
        }
    } else {
        if (strpos($scope, 'Unaffiliated') !== false) {
            $result = DB::queryRaw('SELECT individuals.*, teams.name AS team_name FROM individuals' . ' LEFT JOIN teams ON individuals.team=teams.team_id' . ' WHERE individuals.name LIKE "%' . $query . '%" AND email <> "" ORDER BY individuals.name');
            $row = mysqli_fetch_assoc($result);
            $table = false;
            if ($row) {
                $result_table .= <<<HEREDOC
      <h3>Unaffiliated Individuals</h3>
      <table class="indented contrasting">
        <tr>
          <th>Name</th>
          <th>Grade</th>
          <th>Team</th>
        </tr>
HEREDOC;
                $table = true;
            }
            while ($row) {
                $label = htmlentities($row['name']);
                $url = $urlbase . '/Individual?ID=' . htmlentities($row['id']);
                $grade = htmlentities($row['grade']);
                $team = htmlentities($row['team_name']);
                if ($row['team'] == -1) {
                    $team = '<span class="i">Not Assigned</span>';
                }
                $result_table .= "        <tr><td><a href=\"{$url}\">{$label}</a></td><td class=\"text-centered\">{$grade}</td><td>{$team}</td></tr>\n";
                $row = mysqli_fetch_assoc($result);
            }
            if ($table) {
                $result_table .= "      </table>\n";
            }
        }
    }
    if (strpos($scope, 'Team') !== false) {
        $result = DB::queryRaw('SELECT teams.team_id, teams.name, teams.school, schools.name AS school_name' . ' FROM teams LEFT JOIN schools ON teams.school=schools.school_id' . ' WHERE teams.name LIKE "%' . $query . '%" AND teams.deleted="0" ORDER BY teams.name');
        $row = mysqli_fetch_assoc($result);
        $table = false;
        if ($row) {
            $result_table .= <<<HEREDOC
      <h3>Teams</h3>
      <table class="indented contrasting">
        <tr>
          <th>Name</th>
          <th>School</th>
        </tr>
HEREDOC;
            $table = true;
        }
        while ($row) {
            $label = htmlentities($row['name']);
            $url = $urlbase . '/Team?ID=' . htmlentities($row['team_id']);
            $school = htmlentities($row['school_name']);
            $result_table .= "        <tr><td><a href=\"{$url}\">{$label}</a><td>{$school}</td></td></tr>\n";
            $row = mysqli_fetch_assoc($result);
        }
        if ($table) {
            $result_table .= "      </table>\n";
        }
    }
    if (strpos($scope, 'School') !== false) {
        $result = DB::queryRaw('SELECT school_id, name FROM schools WHERE name LIKE "%' . $query . '%" AND deleted="0"');
        $row = mysqli_fetch_assoc($result);
        $table = false;
        if ($row) {
            $result_table .= <<<HEREDOC
      <h3>Schools</h3>
      <table class="indented contrasting">
        <tr>
          <th>Name</th>
        </tr>
HEREDOC;
            $table = true;
        }
        while ($row) {
            $label = htmlentities($row['name']);
            $url = $urlbase . '/School?ID=' . htmlentities($row['school_id']);
            $result_table .= "        <tr><td><a href=\"{$url}\">{$label}</a></td></tr>\n";
            $row = mysqli_fetch_assoc($result);
        }
        if ($table) {
            $result_table .= "      </table>\n";
        }
    }
    if (strpos($scope, 'Coach') !== false) {
        $result = DB::queryRaw('SELECT school_id, name, coach_email FROM schools WHERE coach_email LIKE "%' . $query . '%" AND deleted="0"');
        $row = mysqli_fetch_assoc($result);
        $table = false;
        if ($row) {
            $result_table .= <<<HEREDOC
      <h3>Coaches</h3>
      <table class="indented contrasting">
        <tr>
          <th>Email</th>
          <th>School</th>
        </tr>
HEREDOC;
            $table = true;
        }
        while ($row) {
            $label = htmlentities($row['coach_email']);
            $url = $urlbase . '/School?ID=' . htmlentities($row['school_id']);
            $school = htmlentities($row['name']);
            $result_table .= "        <tr><td><a href=\"{$url}\">{$label}</a></td><td>{$school}</td></tr>\n";
            $row = mysqli_fetch_assoc($result);
        }
        if ($table) {
            $result_table .= "      </table>\n";
        }
    }
    if ($url === null) {
        // No Results
        lmt_page_header('No Results');
        $back_link = back_link();
        echo <<<HEREDOC
      <h1>No Results</h1>
      
      <div class="text-centered">
        No results were found.<br />
        <a href="{$back_link}">&larr; Go Back</a>
      </div>
HEREDOC;
        die;
    }
    if (strpos($result_table, '<a href', strpos($result_table, '<a href') + 1) === false) {
        header('Location: ' . $url);
        die;
    }
    // Multiple matches; show result list
    lmt_page_header('Search Results');
    $back_link = back_link();
    echo <<<HEREDOC
      <h1>Search Results</h1>
      
      <a href="{$back_link}">&larr; Go Back</a><br />
      <br />
{$result_table}
HEREDOC;
}
Esempio n. 30
0
function preview_message()
{
    // Get info for the byline
    $disp_subject = '[LMT ' . intval(map_value('year')) . '] ' . $_POST['subject'];
    lmt_page_header('Email Individuals');
    echo <<<HEREDOC
      <h1>Email Individuals</h1>
      
      <table class="spacious">
        <tr>
          <td>From:</td>
          <td><span class="b">LHS Math Club Mailbot &lt;{$EMAIL_ADDRESS}&gt;</span></td>
        </tr><tr>
          <td>Reply To:&nbsp;</td>
          <td><span class="b">{$LMT_EMAIL}</span><br /></td>
        </tr><tr>
          <td>Subject:</td>
          <td><span class="b">{$disp_subject}</span><br /><br /></td>
        </tr><tr>
          <td>Body:</td>
          <td>{$bb_body}<br /><br /></td>
        </tr><tr>
          <td></td>
          <td>
            <form id="composeMessage" method="post" action="{$_SERVER['REQUEST_URI']}"><div>
              <input type="hidden" name="subject" value="{$subject}" />
              <input type="hidden" name="body" value="{$body}" />
              <input type="hidden" name="email" value="{$email}" />
              <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" />
              <input type="submit" name="lmti_do_reedit_message" value="Back to Editing" />
              <input type="submit" name="lmti_do_post_message" value="Send Message" />
            </div></form>
          </td>
        </tr><tr>
          <td></td>
          <td><span class="small">Please do not click the &quot;Send Message&quot; button twice!</span></td>
        </tr>
      </table>
      

HEREDOC;
}