コード例 #1
0
ファイル: List.php プロジェクト: lhsmath/lhsmath.org
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;
}
コード例 #2
0
ファイル: Individuals.php プロジェクト: lhsmath/lhsmath.org
function show_page($err)
{
    // Put the cursor in the first field
    global $body_onload, $use_rel_external_script;
    $body_onload = 'document.forms[\'lmtIndividualComposeMessage\'].subject.focus();externalLinks();';
    $use_rel_external_script = true;
    lmt_page_header('Email Individuals');
    $message_sent_msg = fetch_alert('msgIndiv');
    // If an error message is given, put it inside this div
    if ($err != '') {
        $err = "\n        <div class=\"error\">{$err}</div><br />\n";
    }
    // Previously-filled data?
    global $subject, $body, $EMAIL_ADDRESS, $LMT_EMAIL;
    // Assemble Page
    echo <<<HEREDOC
      <h1>Email Individuals</h1>
      {$err}{$message_sent_msg}
      
      <div class="instruction">
        Use this page to send an email to all unaffiliated individuals (individuals with
        an email address on file).
      </div><br /><br />
      
      <form id="lmtIndividualComposeMessage" method="post" action="{$_SERVER['REQUEST_URI']}">
        <table class="spacious">
          <tr>
            <td>From:</td>
            <td><span class="b">LMT Mailbot &lt;{$EMAIL_ADDRESS}&gt;</span><br /></td>
          </tr><tr>
            <td>Reply To:&nbsp;</td>
            <td><span class="b">{$LMT_EMAIL}</span></td>
          </tr><tr>
            <td>Subject:</td>
            <td><input type="text" name="subject" value="{$subject}" size="45" maxlength="75" /></td>
          </tr><tr>
            <td>Body:</td>
            <td>
              <textarea name="body" rows="25" cols="80">{$body}</textarea>
              <div class="small">You may use bold, italic, underline, named links and images with
              <a href="http://www.bbcode.org/reference.php" rel="external">bbCode</a>.</div>
              <br />
            </td>
          </tr><tr>
            <td></td>
            <td>
              <input type="hidden" name="xsrf_token" value="{$_SESSION['xsrf_token']}" />
              <input type="submit" name="lmti_do_preview_message" value="Preview Message" />
            </td>
          </tr>
        </table>
      </form>
HEREDOC;
}
コード例 #3
0
ファイル: Full.php プロジェクト: lhsmath/lhsmath.org
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;
}