Example #1
0
 public function editCategoryNotVisibleTime(AcceptanceTester $I)
 {
     $I->logInAsAnAdmin();
     $I->amOnEditCategory(CI_EDITABLE_CATEGORY_ID);
     $title = time() . 'title';
     $I->fillField('title', $title);
     $I->checkOption('#exposed');
     $from = date_time(time() - 10000);
     $until = date_time(time() - 100);
     $I->fillField('available_from', $from);
     $I->fillField('available_until', $until);
     $I->click('Save changes');
     $I->waitForText('Edit category');
     $I->seeCheckboxIsChecked('#exposed');
     $I->seeInField('available_from', $from);
     $I->seeInField('available_until', $until);
     $I->amOnPage('/challenges');
     $I->see($title);
     $I->amOnPage('/challenges?category=' . to_permalink($title));
     $I->see('Category unavailable');
     $I->see('This category is not available. It is open from ' . $from);
     $I->see('until ' . $until);
     $I->amOnAdminHome();
     $I->see($title);
 }
 function _getposteddata()
 {
     $arr['version'] = system_ver();
     $arr['subject'] = $_POST['subject'];
     $arr['content'] = $_POST['content'];
     $author = user_get();
     $arr['author'] = $author['userid'];
     $arr['date'] = !empty($_POST['timestamp']) ? $_POST['timestamp'] : date_time();
     $cats = !empty($_POST['cats']) ? $_POST['cats'] : array();
     $flags = !empty($_POST['flags']) ? $_POST['flags'] : array();
     //$arr['categories'] = array_merge(array_keys($flags), array_keys($cats));
     return $arr;
 }
Example #3
0
    ?>
">
	<?php 
    echo $re[1];
    ?>
    <tr class="header"> 
      <td width="6%" height="25"> <div align="center">去除</div></td>
      <td width="55%"><div align="center">标题</div></td>
      <td width="18%"><div align="center">发布者</div></td>
      <td width="21%"><div align="center">发布时间</div></td>
    </tr>
	<?php 
    while ($r = $empire->fetch($sql)) {
        //时间
        $truetime = date_time($r[truetime], "Y-m-d H:i:s");
        $lastdotime = date_time($r[lastdotime], "Y-m-d H:i:s");
        $oldtitle = $r[title];
        $r[title] = stripSlashes(sub($r[title], 0, 45, false));
        if (empty($r[checked])) {
            $checked = " title='未审核' style='background:#99C4E3'";
        } else {
            $checked = "";
        }
        //会员投稿
        if ($r[ismember]) {
            $r[username] = "<font color=red>" . $r[username] . "</font>";
        }
        $titleurl = sys_ReturnBqTitleLink($r);
        $bgcolor = "#FFFFFF";
        if (strstr("," . $_POST['inid'] . ",", "," . $r[id] . ",")) {
            $bgcolor = "#DBEAF5";
Example #4
0
function ToChangeTime($time, $day)
{
    $truetime = $time - $day * 24 * 3600;
    $date = date_time($truetime, "Y-m-d");
    return $date;
}
Example #5
0
echo '
<table id="hints" class="table table-striped table-hover">
<thead>
  <tr>
    <th>Added</th>
    <th>Hint</th>
    <th>Manage</th>
  </tr>
</thead>
<tbody>
';
$hints = db_select_all('hints', array('id', 'added', 'body'), array('challenge' => $_GET['id']));
foreach ($hints as $hint) {
    echo '
  <tr>
      <td>', date_time($hint['added']), '</td>
      <td>', htmlspecialchars($hint['body']), '</td>
      <td><a href="edit_hint.php?id=', htmlspecialchars(short_description($hint['id'], 100)), '" class="btn btn-xs btn-primary">Edit</a></td>
  </tr>
  ';
}
echo '
</tbody>
</table>

<a href="new_hint.php?id=', htmlspecialchars($_GET['id']), '" class="btn btn-sm btn-warning">Add a new hint</a>
';
section_subhead('Delete challenge: ' . $challenge['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_challenge');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
Example #6
0
    SELECT
       e.id,
       e.message,
       e.added,
       e.added_by,
       e.trace,
       INET_NTOA(e.user_ip) AS user_ip,
       e.user_agent,
       u.team_name
    FROM exceptions AS e
    LEFT JOIN users AS u ON u.id = e.added_by
    ORDER BY e.id DESC
    LIMIT ' . $from . ', ' . $results_per_page);
foreach ($exceptions as $exception) {
    echo '
    <tr>
        <td>', htmlspecialchars($exception['message']), '</td>
        <td>', date_time($exception['added']), '</td>
        <td>', $exception['added_by'] ? '<a href="edit_user.php?id=' . htmlspecialchars($exception['added_by']) . '">' . htmlspecialchars($exception['team_name']) . '</a>' : '<i>Not logged in</i>', '
        </td>
        <td><a href="list_ip_log.php?ip=', htmlspecialchars($exception['user_ip']), '">', htmlspecialchars($exception['user_ip']), '</a></td>
        <td>', htmlspecialchars($exception['trace']), '</td>
        <td>', htmlspecialchars($exception['user_agent']), '</td>
    </tr>
    ';
}
echo '
      </tbody>
    </table>
     ';
foot();
Example #7
0
    FROM users AS u
    LEFT JOIN ip_log AS ipl ON ipl.user_id = u.id
    LEFT JOIN countries AS co ON co.id = u.country_id
    ' . ($search_for ? 'WHERE u.team_name LIKE :search_for_team_name OR u.email LIKE :search_for_email' : '') . (verifySA() ? '' : 'WHERE u.instanceID =' . $_SESSION["IID"]) . '
    GROUP BY u.id
    ORDER BY u.team_name ASC
    LIMIT ' . $from . ', ' . $results_per_page, $values);
pager(CONFIG_SITE_ADMIN_URL . 'list_users/', count($users), $results_per_page, $from);
foreach ($users as $user) {
    echo '
    <tr>
        <td>
            <a href="', CONFIG_SITE_URL, 'user?id=', htmlspecialchars($user['id']), '">', htmlspecialchars($user['team_name']), '</a>
        </td>
        <td><a href="', CONFIG_SITE_ADMIN_URL, 'new_email.php?to=', htmlspecialchars($user['email']), '">', htmlspecialchars($user['email']), '</a></td>
        <td>', date_time($user['added']), '</td>
        <td>', user_class_name($user['class']), '</td>
        <td>', $user['enabled'] ? 'Yes' : 'No', '</td>
        <td><a href="', CONFIG_SITE_ADMIN_URL, 'list_ip_log.php?id=', htmlspecialchars($user['id']), '">', number_format($user['num_ips']), '</a></td>
        <td>
            <a href="', CONFIG_SITE_ADMIN_URL, 'edit_user.php?id=', htmlspecialchars($user['id']), '" class="btn btn-xs btn-primary">Edit</a>
        </td>
    </tr>
    ';
}
echo '
      </tbody>
    </table>
     ';
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/export_csv');
form_hidden('action', 'export');
Example #8
0
/**
 * function bdb_save_comment
 *
 * <p>Saves the content of the $comment array, associating it to the entry-ID $id.</p>
 * <p>$comment must be formatted as the one returned by {@link bdb_parse_entry()}.</p>
 * <p>Returns true on success, or false on failure</p>
 *
 * @param string $id string formatted like "prefixYYMMDD-HHMMSS"
 * @param array $comment array formatted as the one returned by {@link bdb_parse_entry()}
 * @return bool
 * 
 * @see bdb_parse_entry()
 */
function comment_save($id, $comment)
{
    comment_clean($comment);
    $comment = array_change_key_case($comment, CASE_UPPER);
    $comment_dir = bdb_idtofile($id, BDB_COMMENT);
    if (!isset($comment['DATE'])) {
        $comment['DATE'] = date_time();
    }
    $id = bdb_idfromtime(BDB_COMMENT, $comment['DATE']);
    $f = $comment_dir . $id . EXT;
    $str = utils_kimplode($comment);
    if (io_write_file($f, $str)) {
        return $id;
    }
    return false;
}
Example #9
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Site management');
menu_management();
section_subhead('New category');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/new_category');
form_input_text('Title');
form_textarea('Description');
form_input_checkbox('Exposed', true);
form_input_text('Available from', date_time());
form_input_text('Available until', date_time());
form_hidden('action', 'new');
form_button_submit('Create category');
form_end();
foot();
Example #10
0
function print_user_ip_log($user_id, $limit = 0)
{
    validate_id($user_id);
    section_subhead('IP address usage', ($limit ? 'Limited to ' . $limit . ' results ' : '') . button_link('Show all for user', 'list_ip_log?user_id=' . htmlspecialchars($user_id)), false);
    echo '
        <table id="files" class="table table-striped table-hover">
          <thead>
            <tr>
              <th>IP</th>
              <th>Hostname</th>
              <th>First used</th>
              <th>Last used</th>
              <th>Times used</th>
            </tr>
          </thead>
          <tbody>
        ';
    $entries = db_query_fetch_all('
        SELECT
            INET_NTOA(ip) AS ip,
            added,
            last_used,
            times_used
        FROM ip_log
        WHERE user_id = :user_id
        ORDER BY last_used DESC
        ' . ($limit ? 'LIMIT ' . $limit : ''), array('user_id' => $user_id));
    foreach ($entries as $entry) {
        echo '
        <tr>
            <td><a href="', CONFIG_SITE_ADMIN_URL, 'list_ip_log.php?ip=', htmlspecialchars($entry['ip']), '">', htmlspecialchars($entry['ip']), '</a></td>
            <td>', CONFIG_GET_IP_HOST_BY_ADDRESS ? gethostbyaddr($entry['ip']) : '<i>Lookup disabled in config</i>', '</td>
            <td>', date_time($entry['added']), '</td>
            <td>', date_time($entry['last_used']), '</td>
            <td>', number_format($entry['times_used']), '</td>
        </tr>
        ';
    }
    echo '
          </tbody>
        </table>
         ';
}
/**
 * status_view.php
 *
 * @package       mod_organizer
 * @author        Andreas Hruska (andreas.hruska@tuwien.ac.at)
 * @author        Katarzyna Potocka (katarzyna.potocka@tuwien.ac.at)
 * @author        Andreas Windbichler
 * @author        Ivan Šakić
 * @copyright     2014 Academic Moodle Cooperation {@link http://www.academic-moodle-cooperation.org}
 * @license       http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
function organizer_generate_registration_table_content($columns, $params)
{
    global $DB;
    list($cm, $course, $organizer, $context) = get_course_module_data();
    $groupmode = is_group_mode();
    if ($groupmode) {
        $entries = organizer_get_status_table_entries_group($params);
    } else {
        $entries = organizer_get_status_table_entries($params);
    }
    $rows = array();
    foreach ($entries as $entry) {
        $row = new html_table_row();
        foreach ($columns as $column) {
            switch ($column) {
                case 'participants':
                    if ($groupmode) {
                        $members = $DB->get_fieldset_select('groups_members', 'userid', "groupid = {$entry->id}");
                        $list = "<em>{$entry->name}</em><br/ >";
                        foreach ($members as $member) {
                            $idnumber = get_user_idnumber($member);
                            $list .= get_name_link($member) . " ({$idnumber}) " . (isset($entry->comments) ? get_img('i/feedback', '', $entry->comments) : '');
                            if ($member == $entry->applicantid) {
                                $list .= ' ' . get_img('pix/applicant.png', 'applicant', 'This is the person that registered the group.') . '<br/>';
                            } else {
                                $list .= ' ' . get_img('pix/transparent.png', 'applicant', '') . '<br/>';
                            }
                        }
                        $row->cells[] = new html_table_cell($list);
                    } else {
                        $row->cells[] = new html_table_cell(get_name_link($entry->id) . " ({$entry->idnumber})");
                    }
                    break;
                case 'registered':
                    $row->cells[] = new html_table_cell(get_status_icon_new($entry->status));
                    break;
                case 'datetime':
                    $row->cells[] = new html_table_cell(date_time($entry));
                    break;
                case 'appdetails':
                    if ($groupmode) {
                        $row->cells[] = new html_table_cell('PLACEHOLDER');
                    } else {
                        $row->cells[] = new html_table_cell(app_details($params, $entry));
                    }
                    break;
                case 'location':
                    $row->cells[] = new html_table_cell(location_link($entry));
                    break;
                case 'teacher':
                    $row->cells[] = new html_table_cell(teacher_data($params, $entry));
                    break;
                case 'actions':
                    $row->cells[] = new html_table_cell(teacher_action_new($params, $entry));
                    break;
            }
        }
        $rows[] = $row;
    }
    return $rows;
}
Example #12
0
    ' . ($search_for ? 'WHERE u.team_name LIKE :search_for_team_name OR u.email LIKE :search_for_email' : '') . '
    GROUP BY u.id
    ORDER BY u.team_name ASC
    LIMIT ' . $from . ', ' . $results_per_page, $values);
$total_results = isset($total_results) ? $total_results : count($users);
$base_url = CONFIG_SITE_ADMIN_URL . 'list_users' . (isset($_GET['search_for']) ? '?search_for=' . $_GET['search_for'] : '');
pager($base_url, $total_results, $results_per_page, $from);
foreach ($users as $user) {
    echo '
    <tr>
        <td>
            ', country_flag_link($user['country_name'], $user['country_code']), '
            <a href="', CONFIG_SITE_URL, 'user?id=', htmlspecialchars($user['id']), '">', htmlspecialchars($user['team_name']), '</a>
        </td>
        <td><a href="', CONFIG_SITE_ADMIN_URL, 'new_email.php?to=', htmlspecialchars($user['email']), '">', htmlspecialchars($user['email']), '</a></td>
        <td>', date_time($user['added']), '</td>
        <td>', $user['last_active'] ? date_time($user['last_active']) : '<i>Never</i>', '</td>
        <td class="center">', user_class_name($user['class']), '</td>
        <td class="center">', $user['enabled'] ? '<span class="glyphicon glyphicon-ok"></span>' : '<span class="glyphicon glyphicon-remove red"></span>', '</td>
        <td class="center"><a href="', CONFIG_SITE_ADMIN_URL, 'list_ip_log.php?id=', htmlspecialchars($user['id']), '">', number_format($user['num_ips']), '</a></td>
        <td class="center">
            <a href="', CONFIG_SITE_ADMIN_URL, 'edit_user.php?id=', htmlspecialchars($user['id']), '" class="btn btn-xs btn-primary">Edit</a>
        </td>
    </tr>
    ';
}
echo '
      </tbody>
    </table>
     ';
foot();
          <th style="white-space:nowrap;">Challenge</th>
          <th style="white-space:nowrap;">Team name</th>
          <th style="white-space:nowrap;">Added</th>
          <th style="white-space:nowrap;">Flag</th>
          <th style="white-space:nowrap;">Correct</th>
          <th style="white-space:nowrap;">Manage</th>
        </tr>
      </thead>
      <tbody>
    ';
foreach ($submissions as $submission) {
    echo '
    <tr>
        <td><a href="../challenge.php?id=', htmlspecialchars($submission['challenge_id']), '">', htmlspecialchars($submission['challenge_title']), '</a></td>
        <td><a href="/user.php?id=', htmlspecialchars($submission['user_id']), '">', htmlspecialchars($submission['team_name']), '</a></td>
        <td>', date_time($submission['added']), '</td>
        <td style="word-break: break-all;">', htmlspecialchars($submission['flag']), '</td>
        <td>
            ', $submission['correct'] ? '<img src="' . CONFIG_SITE_URL . 'img/accept.png" alt="Correct!" title="Correct!" />' : '<img src="' . CONFIG_SITE_URL . 'img/stop.png" alt="Wrong!" title="Wrong!" />', '
        </td>
        <td>
            <form method="post" action="actions/list_submissions" class="discreet-inline">';
    form_xsrf_token();
    echo '
                <input type="hidden" name="action" value="', $submission['correct'] ? 'mark_incorrect' : 'mark_correct', '" />
                <input type="hidden" name="id" value="', htmlspecialchars($submission['id']), '" />
                <button type="submit" class="btn btn-sm btn-', $submission['correct'] ? 'warning' : 'success', '">Mark ', $submission['correct'] ? 'incorrect' : 'correct', '</button>
            </form>

            <form method="post" action="actions/list_submissions" class="discreet-inline">';
    form_xsrf_token();
Example #14
0
<?php

$html = '';
$html .= '<div class="journey" data-nb="' . $nb_journey . '">';
$html .= '<div class="sumup">';
$html .= '<p class="time">';
$html .= '<span class="main">' . duration($duration) . '</span>';
$html .= '<span class="second">' . date_time($departure_date_time) . ' - ' . date_time($arrival_date_time) . '</span>';
$html .= '</p>';
$html .= '<p class="walking">';
$html .= '<span class="main">' . duration($duration_walking) . '</span>';
$html .= '<span class="second">de marche</span>';
$html .= '</p>';
if ($nb_transfers > 0) {
    $html .= '<p class="transfer">';
    $html .= '<span class="main">' . $nb_transfers . '</span>';
    $html .= '<span class="second">transfert' . ($nb_transfers > 1 ? 's' : '') . '</span>';
    $html .= '</p>';
}
$html .= '</div>';
$html .= '<div class="sections">';
$html .= $html_sections;
$html .= '</div>';
$html .= '</div>';
echo $html;
Example #15
0
 public function makeCategoryAvailable($id)
 {
     $I = $this;
     $I->amOnEditCategory($id);
     $exposed = $I->grabFromDatabase('categories', 'exposed', array('id' => $id));
     $available_from = strtotime($I->grabValueFrom('available_from'));
     $available_until = strtotime($I->grabValueFrom('available_until'));
     if (!$exposed || $available_from > time() || $available_until < time()) {
         $I->checkOption('#exposed');
         $from = date_time(time() - 10000);
         $until = date_time(time() + 10000);
         $I->fillField('available_from', $from);
         $I->fillField('available_until', $until);
         $I->click('Save changes');
     }
 }
Example #16
0
function user_exception_log($user_id, $limit = null)
{
    validate_id($user_id);
    echo '
    <table id="hints" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Message</th>
          <th>Added</th>
          <th>IP</th>
          <th>Trace</th>
        </tr>
      </thead>
      <tbody>
    ';
    $exceptions = db_query_fetch_all('
        SELECT
           e.id,
           e.message,
           e.added,
           e.added_by,
           e.trace,
           INET_NTOA(e.user_ip) AS user_ip,
           u.team_name
        FROM exceptions AS e
        LEFT JOIN users AS u ON u.id = e.added_by
        WHERE e.added_by = :user_id
        ORDER BY e.id DESC
        ' . ($limit ? 'LIMIT ' . $limit : ''), array('user_id' => $user_id));
    foreach ($exceptions as $exception) {
        echo '
    <tr>
        <td>', htmlspecialchars($exception['message']), '</td>
        <td>', date_time($exception['added']), '</td>
        <td><a href="', CONFIG_SITE_ADMIN_URL, 'list_ip_log.php?ip=', htmlspecialchars($exception['user_ip']), '">', htmlspecialchars($exception['user_ip']), '</a></td>
        <td>', htmlspecialchars($exception['trace']), '</td>
    </tr>
    ';
    }
    echo '
      </tbody>
    </table>
     ';
}
Example #17
0
          </tr>
        </thead>
        <tbody>
       ';
        foreach ($submissions as $submission) {
            echo '
              <tr>
                <td>
                    <a href="challenge?id=', htmlspecialchars($submission['challenge_id']), '">
                    ', htmlspecialchars($submission['title']), '
                    </a> (', htmlspecialchars($submission['category_title']), ')
                </td>

                <td>
                    ', get_position_medal($submission['pos'], true), '
                    ', time_elapsed($submission['added'], $submission['available_from']), ' after release (', date_time($submission['added']), ')
                </td>

                <td>', number_format($submission['points']), '</td>
              </tr>
              ';
        }
        echo '
        </tbody>
      </table>
          ';
    } else {
        echo '
      <div class="alert alert-info">
          No challenges solved, yet!
      </div>
Example #18
0
       re.id,
       re.added,
       re.added_by,
       re.rule,
       re.enabled,
       re.white,
       re.priority,
       u.team_name
    FROM restrict_email AS re
    LEFT JOIN users AS u ON re.added_by = u.id
    ORDER BY re.priority ASC');
foreach ($rules as $rule) {
    echo '
    <tr>
        <td>', htmlspecialchars($rule['rule']), '</td>
        <td>', date_time($rule['added']), '</td>
        <td>', htmlspecialchars($rule['team_name']), '</td>
        <td>
            ', $rule['white'] ? '<img src="' . CONFIG_SITE_URL_STATIC_RESOURCES . 'img/accept.png" alt="Whitelisted" title="Whitelisted" />' : '<img src="' . CONFIG_SITE_URL_STATIC_RESOURCES . 'img/stop.png" alt="Blacklisted" title="Blacklisted" />', '
        </td>
        <td>', number_format($rule['priority']), '</td>
        <td>', $rule['enabled'] ? 'Yes' : 'No', '</td>
        <td>
            <a href="edit_restrict_email.php?id=', htmlspecialchars($rule['id']), '" class="btn btn-xs btn-primary">Edit</a>
        </td>
    </tr>
    ';
}
echo '
      </tbody>
    </table>
Example #19
0
           ipl.added,
           ipl.last_used,
           ipl.times_used,
           u.team_name,
           u.id AS user_id
        FROM ip_log AS ipl
        LEFT JOIN users AS u ON ipl.user_id = u.id
        WHERE ipl.ip=INET_ATON(:ip)', array('ip' => $_GET['ip']));
        $host = CONFIG_GET_IP_HOST_BY_ADDRESS ? gethostbyaddr($_GET['ip']) : '<i>Lookup disabled in config</i>';
        foreach ($entries as $entry) {
            echo '
    <tr>
        <td>
            <a href="list_ip_log.php?id=', htmlspecialchars($entry['user_id']), '">
                ', htmlspecialchars($entry['team_name']), '
            </a>
        </td>
        <td>', $host, '</td>
        <td>', date_time($entry['added']), '</td>
        <td>', date_time($entry['last_used']), '</td>
        <td>', number_format($entry['times_used']), '</td>
    </tr>
    ';
        }
        echo '
      </tbody>
    </table>
     ';
    }
}
foot();
Example #20
0
/**
 *
 * @param array entry 	contents
 * @param string|null 	entry id, null if can be deducted from the date field of $entry; 
 * 						defaults to null
 *
 * @param bool 			updates entry index; defaults to true	
 *
 *
 * @return integer 		-1 failure while storing preliminar draft, abort. Index not touched.
 * 						-2 index updated succesfully, but draft doesn't exist anymore 
 * 						   (should never happen!) OR
 * 						   failure while trying to move draft to entry path, draft does not exist anymore
 * 						   index not touched
 * 						-3 error while moving draft still exists, index written succesfully but rolled back
 * 						-4 failure while saving to index, aborted (draft still exists)
 *
 *
 */
function entry_save($entry, $id = null, $update_index = true)
{
    // PHASE 1 : prepare entry
    if (!$id) {
        if (!@$entry['date']) {
            $entry['date'] = date_time();
        }
        $id = bdb_idfromtime(BDB_ENTRY, $entry['date']);
    }
    // PHASE 2 : Store
    // secure data as DRAFT
    // (entry is also implicitly entry_prepare()'d here)
    $ret = draft_save($entry, $id);
    do_action('publish_post', $id, $entry);
    if ($ret === false) {
        return -1;
        // FAILURE: ABORT
    }
    // PHASE 3 : Update index
    $delete_cats = array();
    $all_cats = @$entry['categories'];
    $update_title = true;
    if ($old_entry = entry_parse($id)) {
        if ($all_cats) {
            $delete_cats = array_diff($old_entry['categories'], $all_cats);
        }
        $all_cats = $all_cats ? array_merge($all_cats, $old_entry['categories']) : $old_entry['categories'];
        $update_title = $entry['subject'] != $old_entry['subject'];
    }
    /*
    echo 'old';
    print_r($old_entry['categories']);
    echo 'new';
    print_r($entry['categories']);
    echo 'del';
    print_r($delete_cats);
    echo 'all';
    print_r($all_cats);
    */
    $INDEX =& entry_init();
    $ok = $update_index ? $INDEX->add($id, $entry, $delete_cats, $update_title) : true;
    // PHASE 4 : index updated; let's move back the entry
    if ($ok) {
        $entryd = entry_dir($id, true);
        $entryf = $entryd . $id . EXT;
        $draftf = draft_exists($id);
        if ($draftf === false) {
            // this should never happen!
            if ($update_index) {
                $INDEX->delete($id, $all_cats);
            }
            return -2;
        }
        fs_delete($entryf);
        fs_mkdir($entryd);
        $ret = rename($draftf, $entryf);
        if (!$ret) {
            if (draft_exists($id)) {
                // rollback changes in the index
                // (keep the draft file)
                if ($update_index) {
                    $INDEX->delete($id, $all_cats);
                }
                return -3;
            } else {
                return -2;
            }
        } else {
            // SUCCESS : delete draft, move comments along
            draft_to_entry($id);
            return $id;
        }
    }
    return -4;
}
Example #21
0
    WHERE
       c.category = :category AND
       c.exposed = 1
    ORDER BY c.points ASC, c.id ASC', array('user_id_1' => $_SESSION['id'], 'user_id_2' => $_SESSION['id'], 'user_id_3' => $_SESSION['id'], 'user_id_4' => $_SESSION['id'], 'category' => $current_category['id']));
echo '<div id="challenges-container" class="panel-group">';
foreach ($challenges as $challenge) {
    // if the challenge isn't available yet, display a message and continue to next challenge
    if ($time < $challenge['available_from']) {
        echo '
        <div class="panel panel-default challenge-container">
            <div class="panel-heading">
                <h4 class="challenge-head">Hidden challenge worth ', number_format($challenge['points']), 'pts</h4>
            </div>
            <div class="panel-body">
                <div class="challenge-description">
                    Available in ', time_remaining($challenge['available_from']), ' (from ', date_time($challenge['available_from']), ' until ', date_time($challenge['available_until']), ')
                </div>
            </div>
        </div>';
        continue;
    }
    $remaining_submissions = $challenge['num_attempts_allowed'] ? $challenge['num_attempts_allowed'] - $challenge['num_submissions'] : 1;
    $panel_class = "panel-default";
    if (!$remaining_submissions) {
        $panel_class = "panel-danger";
    } else {
        if ($challenge['correct_submission_added']) {
            $panel_class = "panel-success";
        }
    }
    echo '
Example #22
0
          </tr>
        </thead>
        <tbody>
       ';
        foreach ($submissions as $submission) {
            echo '
              <tr>
                <td>
                    <a href="challenge?id=', htmlspecialchars($submission['challenge_id']), '">
                    ', htmlspecialchars($submission['title']), '
                    </a> (', htmlspecialchars($submission['category_title']), ')
                </td>

                <td>
                    ', get_position_medal($submission['pos'], true), '
                    ', time_elapsed($submission['added'], $submission['available_from']), ' ', lang_get('after_release'), ' (', date_time($submission['added']), ')
                </td>

                <td>', number_format($submission['points']), '</td>
              </tr>
              ';
        }
        echo '
        </tbody>
      </table>
          ';
    } else {
        message_inline_blue(lang_get('no_challenges_solved'));
    }
    cache_end(CONST_CACHE_NAME_USER . $_GET['id']);
}
Example #23
0
$html .= '<div class="circle" style="border-color:#' . $color . '; background-color:#' . $color . ';"></div>';
$html .= '</div>';
$html .= '<div class="cell">';
$html .= '<span class="from">' . $from['name'] . '</span>';
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="row middle">';
$html .= '<div class="cell">';
$html .= '<span class="icon" style="color:#' . $color . ';"></span>';
$html .= '</div>';
$html .= '<div class="cell road">';
$html .= '<div class="line" style="border-color:#' . $color . '; background-color:#' . $color . ';"></div>';
$html .= '</div>';
$html .= '<div class="cell">';
$html .= '<span class="direction">' . $displayInformations['direction'] . '</span>';
$html .= '<span class="stop_duration">' . count($stop_date_times) . ' arrêts : ' . duration($duration) . '</span>';
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="row end">';
$html .= '<div class="cell">';
$html .= '<span class="arrival_date_time">' . date_time($arrival_date_time) . '</span>';
$html .= '</div>';
$html .= '<div class="cell road">';
$html .= '<div class="circle" style="border-color:#' . $color . '; background-color:#' . $color . ';"></div>';
$html .= '</div>';
$html .= '<div class="cell">';
$html .= '<span class="to">' . $to['name'] . '</span>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
echo $html;
Example #24
0
function check_server_configuration()
{
    // check for DB and PHP time mismatch
    $dbInfo = db_query_fetch_one('SELECT UNIX_TIMESTAMP() AS timestamp');
    $time = time();
    $error = abs($time - $dbInfo['timestamp']);
    if ($error >= 5) {
        message_inline_red('Database and PHP times are out of sync.
        This will likely cause problems.
        DB time: ' . date_time($dbInfo['timestamp']) . ', PHP time: ' . date_time($time) . ' (' . $error . ' seconds off).
        Maybe you have different time zones set?');
    }
    // check that our writable dirs are writable
    if (!is_writable(CONFIG_PATH_FILE_WRITABLE)) {
        message_inline_red('Writable directory does not exist, or your web server does not have write access to it.
        You will not be able to upload files or perform caching.');
    }
    if (version_compare(PHP_VERSION, '5.3.7', '<')) {
        message_inline_red('Your version of PHP is too old. You need at least 5.3.7. You are running: ' . PHP_VERSION);
    }
}
Example #25
0
<?php

require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
validate_id($_GET['id']);
$category = db_select_one('categories', array('*'), array('id' => $_GET['id']));
head('Site management');
menu_management();
section_subhead('Edit category: ' . $category['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_category');
form_input_text('Title', $category['title']);
form_textarea('Description', $category['description']);
form_input_checkbox('Exposed', $category['exposed']);
form_input_text('Available from', date_time($category['available_from']));
form_input_text('Available until', date_time($category['available_until']));
form_hidden('action', 'edit');
form_hidden('id', $_GET['id']);
form_button_submit('Save changes');
form_end();
section_subhead('Delete category: ' . $category['title']);
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/edit_category');
form_input_checkbox('Delete confirmation');
form_hidden('action', 'delete');
form_hidden('id', $_GET['id']);
message_inline_red('Warning! This will delete all challenges under this category, as well as all submissions, files, and hints related those challenges!');
form_button_submit('Delete category', 'danger');
form_end();
foot();
Example #26
0
function check_server_configuration()
{
    // check for DB and PHP time mismatch
    $dbInfo = db_query_fetch_one('SELECT UNIX_TIMESTAMP() AS timestamp');
    $time = time();
    $error = abs($time - $dbInfo['timestamp']);
    if ($error >= 5) {
        message_inline_red('Database and PHP times are out of sync.
        This will likely cause problems.
        DB time: ' . date_time($dbInfo['timestamp']) . ', PHP time: ' . date_time($time) . ' (' . $error . ' seconds off).
        Maybe you have different time zones set?');
    }
    // check that our writable dirs are writable
    foreach (get_directory_list_recursive(CONST_PATH_FILE_WRITABLE) as $dir) {
        if (!is_writable($dir)) {
            message_inline_red('Directory (' . $dir . ') must be writable by Apache.');
        }
    }
    if (version_compare(PHP_VERSION, CONST_MIN_REQUIRED_PHP_VERSION, '<')) {
        message_inline_red('Your version of PHP is too old. You need at least ' . CONST_MIN_REQUIRED_PHP_VERSION . '. You are running: ' . PHP_VERSION);
    }
}
        <td ><?php 
        echo "<strong>Orginal Pincode</strong> <br />" . $row['mail_zip'] . "<br /><br /><strong>Changed From</strong><br />" . $row['previous_pincode'];
        ?>
</td>
        
        <td ><?php 
        echo $row['fe'] . "<br /><span class=sub_mobile>" . $fes_contact_no . "</span><br /><br />Requested By<br />\r\n" . $row['previous_fes'] . "<br /><span class=sub_mobile>" . $pre_fes_contact_no . "</span>";
        ?>
</td>
        <td ><?php 
        echo get_status($row['ivr_flag']);
        ?>
</td>
		
        <td ><?php 
        echo date_time($row['upload_date_time']);
        ?>
</td>
		
       
		
      
    </tr>
	<?php 
    }
} else {
    ?>
    <tr>
    	<td colspan="11"><span style="color:#FF0000;">No Record Found</span></td>
    </tr>
    <?php 
Example #28
0
function user_ip_log($user_id)
{
    validate_id($user_id);
    echo '
        <table id="files" class="table table-striped table-hover">
          <thead>
            <tr>
              <th>IP</th>
              <th>Hostname</th>
              <th>First used</th>
              <th>Last used</th>
              <th>Times used</th>
            </tr>
          </thead>
          <tbody>
        ';
    $entries = db_select_all('ip_log', array('INET_NTOA(ip) AS ip', 'added', 'last_used', 'times_used'), array('user_id' => $_GET['id']));
    foreach ($entries as $entry) {
        echo '
        <tr>
            <td><a href="list_ip_log.php?ip=', htmlspecialchars($entry['ip']), '">', htmlspecialchars($entry['ip']), '</a></td>
            <td>', CONFIG_GET_IP_HOST_BY_ADDRESS ? gethostbyaddr($entry['ip']) : '<i>Lookup disabled in config</i>', '</td>
            <td>', date_time($entry['added']), '</td>
            <td>', date_time($entry['last_used']), '</td>
            <td>', number_format($entry['times_used']), '</td>
        </tr>
        ';
    }
    echo '
          </tbody>
        </table>
         ';
}