当前位置: 首页>>代码示例>>PHP>>正文


PHP message_generic函数代码示例

本文整理汇总了PHP中message_generic函数的典型用法代码示例。如果您正苦于以下问题:PHP message_generic函数的具体用法?PHP message_generic怎么用?PHP message_generic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了message_generic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: register_account

function register_account($email, $password, $team_name, $country, $type = null, $phoneNo, $age, $eduI, $eduLevel, $fullName, $instanceID)
{
    if (!CONFIG_ACCOUNTS_SIGNUP_ALLOWED) {
        message_error('Registration is currently closed.');
    }
    if (empty($email) || empty($password) || empty($team_name)) {
        message_error('Please fill in all the details correctly.');
    }
    if (isset($type) && !is_valid_id($type)) {
        message_error('That does not look like a valid team type.');
    }
    if (strlen($team_name) > CONFIG_MAX_TEAM_NAME_LENGTH || strlen($team_name) < CONFIG_MIN_TEAM_NAME_LENGTH) {
        message_error('Your team name was too long or too short.');
    }
    validate_email($email);
    if (!allowed_email($email)) {
        message_error('Email not on whitelist. Please choose a whitelisted email or contact organizers.');
    }
    $num_countries = db_select_one('countries', array('COUNT(*) AS num'));
    if (!isset($country) || !is_valid_id($country) || $country > $num_countries['num']) {
        message_error('Please select a valid country.');
    }
    $user = db_select_one('users', array('id'), array('team_name' => $team_name, 'email' => $email), null, 'OR');
    if ($user['id']) {
        message_error('An account with this team name or email already exists.');
    }
    $user_id = db_insert('users', array('email' => $email, 'passhash' => make_passhash($password), 'team_name' => $team_name, 'added' => time(), 'enabled' => CONFIG_ACCOUNTS_DEFAULT_ENABLED ? '1' : '0', 'user_type' => isset($type) ? $type : 0, 'country_id' => $country, 'DOB' => $age, 'mobileNo' => $phoneNo, 'eduInstitution' => $eduI, 'eduLevel' => $eduLevel, 'fullName' => $fullName, 'instanceID' => $instanceID));
    // insertion was successful
    if ($user_id) {
        // log signup IP
        log_user_ip($user_id);
        // if account isn't enabled by default, display message and die
        if (!CONFIG_ACCOUNTS_DEFAULT_ENABLED) {
            message_generic('Signup successful', 'Thank you for registering!
            Your chosen email is: ' . htmlspecialchars($email) . '.
            Make sure to check your spam folder as emails from us may be placed into it.
            Please stay tuned for updates!');
        } else {
            return true;
        }
    }
    // no rows were inserted
    return false;
}
开发者ID:ZlhlmChZ,项目名称:source-code-mell,代码行数:44,代码来源:session.inc.php

示例2: enforce_authentication

<?php

require '../../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    validate_xsrf_token($_POST[CONST_XSRF_TOKEN_KEY]);
    if ($_POST['action'] == 'new') {
        $successfully_sent_to = send_email(csv_email_list_to_array($_POST['to']), $_POST['subject'], $_POST['body'], csv_email_list_to_array($_POST['cc']), csv_email_list_to_array($_POST['bcc']), CONFIG_EMAIL_FROM_EMAIL, CONFIG_EMAIL_FROM_NAME, CONFIG_EMAIL_REPLYTO_EMAIL, CONFIG_EMAIL_REPLYTO_NAME, isset($_POST['html_email']) ? true : false);
        message_generic('Status', 'Successfully sent emails to ' . count($successfully_sent_to) . ' addresses.
            List: ' . implode(', ', $successfully_sent_to));
    }
}
开发者ID:janglapuk,项目名称:mellivora,代码行数:12,代码来源:new_email.php

示例3: section_head

 section_head(htmlspecialchars($user['team_name']), country_flag_link($user['country_name'], $user['country_code'], true), false);
 if (!$user['competing']) {
     message_inline_blue(lang_get('non_competing_user'));
 }
 $challenges = db_query_fetch_all('
     SELECT
        ca.title,
        (SELECT SUM(ch.points) FROM challenges AS ch JOIN submissions AS s ON s.challenge = ch.id AND s.user_id = :user_id AND s.correct = 1 WHERE ch.category = ca.id GROUP BY ch.category) AS points,
        (SELECT SUM(ch.points) FROM challenges AS ch WHERE ch.category = ca.id GROUP BY ch.category) AS category_total
     FROM categories AS ca
     WHERE
       ca.available_from < UNIX_TIMESTAMP() AND
       ca.exposed = 1
     ORDER BY ca.title ASC', array('user_id' => $_GET['id']));
 if (empty($challenges)) {
     message_generic(lang_get('no_information'), lang_get('no_solves'), false);
 }
 $user_total = 0;
 $ctf_total = 0;
 foreach ($challenges as $challenge) {
     echo '<strong>', htmlspecialchars($challenge['title']), '</strong>, ', number_format($challenge['points']), ' / ', number_format($challenge['category_total']), ' (', round($challenge['points'] / max(1, $challenge['category_total']) * 100), '%)';
     progress_bar($challenge['points'] / max(1, $challenge['category_total']) * 100);
     $user_total += $challenge['points'];
     $ctf_total += $challenge['category_total'];
 }
 echo lang_get('total_solves'), ' ', number_format($user_total), ' / ', number_format($ctf_total), ' (', round($user_total / $ctf_total * 100, 1), '%)';
 section_head(lang_get('solved_challenges'));
 $submissions = db_query_fetch_all('
     SELECT
        s.added,
        ((SELECT COUNT(*) FROM submissions AS ss WHERE ss.correct = 1 AND ss.added < s.added AND ss.challenge=s.challenge)+1) AS pos,
开发者ID:Gustibimo,项目名称:mellivora,代码行数:31,代码来源:user.php

示例4: db_query_fetch_one

 $challenge = db_query_fetch_one('
     SELECT
        ch.title,
        ch.description,
        ch.available_from AS challenge_available_from,
        ca.title AS category_title,
        ca.available_from AS category_available_from
     FROM challenges AS ch
     LEFT JOIN categories AS ca ON ca.id = ch.category
     WHERE ch.id = :id', array('id' => $_GET['id']));
 if (empty($challenge)) {
     message_generic('Sorry', 'No challenge found with this ID', false);
 }
 $now = time();
 if ($challenge['challenge_available_from'] > $now || $challenge['category_available_from'] > $now) {
     message_generic('Sorry', 'This challenge is not yet available', false);
 }
 $submissions = db_query_fetch_all('SELECT
         u.id AS user_id,
         u.team_name,
         s.added,
         c.available_from
       FROM users AS u
       LEFT JOIN submissions AS s ON s.user_id = u.id
       LEFT JOIN challenges AS c ON c.id = s.challenge
       WHERE
          u.competing = 1 AND
          s.challenge = :id AND
          s.correct = 1
       ORDER BY s.added ASC', array('id' => $_GET['id']));
 section_head($challenge['title']);
开发者ID:ZlhlmChZ,项目名称:source-code-mell,代码行数:31,代码来源:challenge.php

示例5: db_query_fetch_all

if (cache_start('hints', CONFIG_CACHE_TIME_HINTS)) {
    $hints = db_query_fetch_all('
        SELECT
           h.id,
           h.added,
           h.body,
           c.title,
           ca.title AS category_title
        FROM hints AS h
        LEFT JOIN challenges AS c ON c.id = h.challenge
        LEFT JOIN categories AS ca ON ca.id = c.category
        WHERE c.available_from < UNIX_TIMESTAMP() AND c.available_until > UNIX_TIMESTAMP() AND h.visible = 1
        ORDER BY h.id DESC
    ');
    if (!count($hints)) {
        message_generic("Hints", "No hints have been made available yet.", false);
    }
    section_head('Hints');
    echo '
        <table id="files" class="table table-striped table-hover">
          <thead>
            <tr>
              <th>Category</th>
              <th>Challenge</th>
              <th>Added</th>
              <th>Hint</th>
            </tr>
          </thead>
          <tbody>
        ';
    foreach ($hints as $hint) {
开发者ID:ZlhlmChZ,项目名称:source-code-mell,代码行数:31,代码来源:hints.php

示例6: register_account

function register_account($email, $password, $team_name, $country, $type = null)
{
    if (!CONFIG_ACCOUNTS_SIGNUP_ALLOWED) {
        message_error(lang_get('registration_closed'));
    }
    if (empty($email) || empty($password) || empty($team_name)) {
        message_error(lang_get('please_fill_details_correctly'));
    }
    if (isset($type) && !is_valid_id($type)) {
        message_error(lang_get('invalid_team_type'));
    }
    if (strlen($team_name) > CONFIG_MAX_TEAM_NAME_LENGTH || strlen($team_name) < CONFIG_MIN_TEAM_NAME_LENGTH) {
        message_error('team_name_too_long_or_short');
    }
    validate_email($email);
    if (!allowed_email($email)) {
        message_error(lang_get('email_not_whitelisted'));
    }
    $num_countries = db_select_one('countries', array('COUNT(*) AS num'));
    if (!isset($country) || !is_valid_id($country) || $country > $num_countries['num']) {
        message_error(lang_get('please_supply_country_code'));
    }
    $user = db_select_one('users', array('id'), array('team_name' => $team_name, 'email' => $email), null, 'OR');
    if ($user['id']) {
        message_error(lang_get('user_already_exists'));
    }
    $user_id = db_insert('users', array('email' => $email, 'passhash' => make_passhash($password), 'team_name' => $team_name, 'added' => time(), 'enabled' => CONFIG_ACCOUNTS_DEFAULT_ENABLED ? '1' : '0', 'user_type' => isset($type) ? $type : 0, 'country_id' => $country));
    // insertion was successful
    if ($user_id) {
        // log signup IP
        log_user_ip($user_id);
        // signup email
        $email_subject = lang_get('signup_email_subject', array('site_name' => CONFIG_SITE_NAME));
        // body
        $email_body = lang_get('signup_email_success', array('team_name' => htmlspecialchars($team_name), 'site_name' => CONFIG_SITE_NAME, 'signup_email_availability' => CONFIG_ACCOUNTS_DEFAULT_ENABLED ? lang_get('signup_email_account_availability_message_login_now') : lang_get('signup_email_account_availability_message_login_later'), 'signup_email_password' => CONFIG_ACCOUNTS_EMAIL_PASSWORD_ON_SIGNUP ? lang_get('your_password_is') . ': ' . $password : lang_get('your_password_was_set')));
        // send details to user
        send_email(array($email), $email_subject, $email_body);
        // if account isn't enabled by default, display message and die
        if (!CONFIG_ACCOUNTS_DEFAULT_ENABLED) {
            message_generic(lang_get('signup_successful'), lang_get('signup_successful_text', array('email' => htmlspecialchars($email))));
        } else {
            return true;
        }
    }
    // no rows were inserted
    return false;
}
开发者ID:azizjonm,项目名称:ctf-engine,代码行数:47,代码来源:session.inc.php

示例7: UNIX_TIMESTAMP

        h.body,
        c.title,
        ca.title AS category_title
     FROM hints AS h
     LEFT JOIN challenges AS c ON c.id = h.challenge
     LEFT JOIN categories AS ca ON ca.id = c.category
     WHERE
       c.available_from < UNIX_TIMESTAMP() AND
       c.available_until > UNIX_TIMESTAMP() AND
       h.visible = 1 AND
       c.exposed = 1 AND
       ca.exposed = 1
     ORDER BY h.id DESC
 ');
 if (!count($hints)) {
     message_generic(lang_get('hints'), lang_get('no_hints_available'), false);
 }
 section_head('Hints');
 echo '
     <table id="files" class="table table-striped table-hover">
       <thead>
         <tr>
           <th>', lang_get('category'), '</th>
           <th>', lang_get('challenge'), '</th>
           <th>', lang_get('added'), '</th>
           <th>', lang_get('hint'), '</th>
         </tr>
       </thead>
       <tbody>
     ';
 foreach ($hints as $hint) {
开发者ID:janglapuk,项目名称:mellivora,代码行数:31,代码来源:hints.php

示例8: foreach

echo '<div id="categories-menu">
<ul id="categories-menu">';
foreach ($categories as $cat) {
    if ($time < $cat['available_from'] || $time > $cat['available_until']) {
        echo '<li class="disabled">
        <a data-container="body" data-toggle="tooltip" data-placement="top" class="has-tooltip" title="Available in ' . time_remaining($cat['available_from']) . '.">', htmlspecialchars($cat['title']), '</a>
        </li>';
    } else {
        echo '<li ', $current_category['id'] == $cat['id'] ? ' class="active"' : '', '><a href="', CONFIG_SITE_URL, 'challenges?category=', htmlspecialchars($cat['id']), '">', htmlspecialchars($cat['title']), '</a></li>';
    }
}
echo '</ul>
</div>';
// check that the category is actually available for display
if ($time < $current_category['available_from'] || $time > $current_category['available_until']) {
    message_generic('Category unavailable', 'This category is not available. It is open from ' . date_time($current_category['available_from']) . ' (' . time_remaining($current_category['available_from']) . ' from now) until ' . date_time($current_category['available_until']) . ' (' . time_remaining($current_category['available_until']) . ' from now)', false);
}
// write out the category description, if one exists
if ($current_category['description']) {
    echo '<div id="category-description">', $bbc->parse($current_category['description']), '</div>';
}
// get all the challenges for the selected category
$challenges = db_query_fetch_all('
    SELECT
       c.id,
       c.title,
       c.description,
       c.available_from,
       c.available_until,
       c.points,
       c.num_attempts_allowed,
开发者ID:dirvuk,项目名称:mellivora,代码行数:31,代码来源:challenges.php

示例9: prefer_ssl

<?php

require '../../include/ctf.inc.php';
prefer_ssl();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($_POST['action'] == 'register') {
        if (CONFIG_RECAPTCHA_ENABLE_PRIVATE) {
            validate_captcha();
        }
        validate_email($_POST['email']);
        $recruit = db_select_one('recruit', array('id'), array('email' => $_POST['email']));
        if ($recruit['id']) {
            message_generic('Thank you', 'Your email was already registered!');
        }
        $id = db_insert('recruit', array('added' => time(), 'user_id' => $_SESSION['id'], 'name' => $_POST['name'], 'email' => $_POST['email'], 'city' => $_POST['city'], 'country' => $_POST['country']));
        if ($id) {
            message_generic('Success', 'The email ' . htmlspecialchars($_POST['email']) . ' has been registered. Thanks!');
        } else {
            message_error('Could not register interest. You must not be interested enough!');
        }
    }
}
开发者ID:azizjonm,项目名称:ctf-engine,代码行数:22,代码来源:recruit.php

示例10: prefer_ssl

<?php

require '../../include/mellivora.inc.php';
prefer_ssl();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($_POST['action'] == 'register') {
        if (CONFIG_RECAPTCHA_ENABLE_PUBLIC) {
            validate_captcha();
        }
        validate_email($_POST['email']);
        $interest = db_select_one('interest', array('id'), array('email' => $_POST['email']));
        if ($interest['id']) {
            message_error('You have already registered your interest!');
        }
        $id = db_insert('interest', array('added' => time(), 'name' => $_POST['name'], 'email' => $_POST['email'], 'secret' => generate_random_string(40)));
        if ($id) {
            message_generic('Success', 'The email ' . htmlspecialchars($_POST['email']) . ' has been registered. We look forward to seeing you in our next competition!');
        } else {
            message_error('Could not register interest. You must not be interested enough!');
        }
    }
}
开发者ID:dirvuk,项目名称:mellivora,代码行数:22,代码来源:interest.php

示例11: enforce_authentication

<?php

require '../../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    validate_xsrf_token($_POST['xsrf_token']);
    if ($_POST['action'] == 'test') {
        if (allowed_email($_POST['email'])) {
            message_generic('Yes', 'A user will be able to sign up with this email.');
        } else {
            message_generic('No', 'A user will NOT be able to sign up with this email.');
        }
    }
}
开发者ID:jpnelson,项目名称:mellivora,代码行数:14,代码来源:test_restrict_email.php

示例12: enforce_authentication

require '../../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    validate_id($_POST['id']);
    validate_xsrf_token($_POST[CONST_XSRF_TOKEN_KEY]);
    if ($_POST['action'] == 'edit') {
        validate_email($_POST['email']);
        db_update('users', array('email' => $_POST['email'], 'team_name' => $_POST['team_name'], 'enabled' => $_POST['enabled'], 'competing' => $_POST['competing'], 'country_id' => $_POST['country']), array('id' => $_POST['id']));
        invalidate_cache(CONST_CACHE_NAME_USER . $_POST['id']);
        redirect(CONFIG_SITE_ADMIN_RELPATH . 'list_users.php?generic_success=1');
    } else {
        if ($_POST['action'] == 'delete') {
            if (!$_POST['delete_confirmation']) {
                message_error('Please confirm delete');
            }
            db_delete('users', array('id' => $_POST['id']));
            db_delete('submissions', array('user_id' => $_POST['id']));
            db_delete('ip_log', array('user_id' => $_POST['id']));
            db_delete('cookie_tokens', array('user_id' => $_POST['id']));
            invalidate_cache(CONST_CACHE_NAME_USER . $_POST['id']);
            redirect(CONFIG_SITE_ADMIN_RELPATH . 'list_users.php?generic_success=1');
        } else {
            if ($_POST['action'] == 'reset_password') {
                $new_password = generate_random_string(8);
                $new_passhash = make_passhash($new_password);
                db_update('users', array('passhash' => $new_passhash), array('id' => $_POST['id']));
                message_generic('Success', 'Users new password is: ' . $new_password);
            }
        }
    }
}
开发者ID:azizjonm,项目名称:ctf-engine,代码行数:31,代码来源:edit_user.php

示例13: array

        ch.description,
        ch.available_from AS challenge_available_from,
        ca.title AS category_title,
        ca.available_from AS category_available_from
     FROM challenges AS ch
     LEFT JOIN categories AS ca ON ca.id = ch.category
     WHERE
        ch.id = :id AND
        ch.exposed = 1 AND
        ca.exposed = 1', array('id' => $_GET['id']));
 if (empty($challenge)) {
     message_generic(lang_get('sorry'), lang_get('no_challenge_for_id'), false);
 }
 $now = time();
 if ($challenge['challenge_available_from'] > $now || $challenge['category_available_from'] > $now) {
     message_generic(lang_get('sorry'), lang_get('challenge_not_available'), false);
 }
 $submissions = db_query_fetch_all('SELECT
         u.id AS user_id,
         u.team_name,
         s.added,
         c.available_from
       FROM users AS u
       LEFT JOIN submissions AS s ON s.user_id = u.id
       LEFT JOIN challenges AS c ON c.id = s.challenge
       WHERE
          u.competing = 1 AND
          s.challenge = :id AND
          s.correct = 1
       ORDER BY s.added ASC', array('id' => $_GET['id']));
 section_head($challenge['title']);
开发者ID:azizjonm,项目名称:ctf-engine,代码行数:31,代码来源:challenge.php

示例14: validate_captcha

        }
    }
    // stage 1, part 2
    if ($_POST['action'] == 'reset_password') {
        if (CONFIG_RECAPTCHA_ENABLE_PUBLIC) {
            validate_captcha();
        }
        $user = db_select_one('users', array('id', 'team_name', 'email'), array('email' => $_POST[md5(CONFIG_SITE_NAME . 'EMAIL')]));
        if ($user['id']) {
            $auth_key = hash('sha256', generate_random_string(128));
            db_insert('reset_password', array('added' => time(), 'user_id' => $user['id'], 'ip' => get_ip(true), 'auth_key' => $auth_key));
            $email_subject = 'Password recovery for team ' . htmlspecialchars($user['team_name']);
            // body
            $email_body = htmlspecialchars($user['team_name']) . ', please follow the link below to reset your password:' . "\r\n" . "\r\n" . CONFIG_SITE_URL . 'reset_password?action=choose_password&auth_key=' . $auth_key . '&id=' . $user['id'] . "\r\n" . "\r\n" . 'Regards,' . "\r\n" . CONFIG_SITE_NAME;
            // send details to user
            send_email(array($user['email']), $email_subject, $email_body);
        }
        message_generic('Success', 'If the email you provided was found in the database, an email has now been sent to it with further instructions!');
    } else {
        if ($_POST['action'] == 'choose_password' && is_valid_id($auth['user_id'])) {
            $new_password = $_POST[md5(CONFIG_SITE_NAME . 'PWD')];
            if (empty($new_password)) {
                message_error('You can\'t have an empty password');
            }
            $new_passhash = make_passhash($new_password);
            db_update('users', array('passhash' => $new_passhash), array('id' => $auth['user_id']));
            db_delete('reset_password', array('user_id' => $auth['user_id']));
            message_generic('Success', 'Your password has been reset.');
        }
    }
}
开发者ID:azizjonm,项目名称:ctf-engine,代码行数:31,代码来源:reset_password.php

示例15: validate_id

<?php

require '../include/mellivora.inc.php';
validate_id(array_get($_GET, 'id'));
head(lang_get('user_details'));
if (cache_start(CONST_CACHE_NAME_USER . $_GET['id'], CONFIG_CACHE_TIME_USER)) {
    $user = db_query_fetch_one('
        SELECT
            u.team_name,
            u.competing,
            co.country_name,
            co.country_code
        FROM users AS u
        LEFT JOIN countries AS co ON co.id = u.country_id
        WHERE
          u.id = :user_id', array('user_id' => $_GET['id']));
    if (empty($user)) {
        message_generic(lang_get('sorry'), lang_get('no_user_found'), false);
    }
    section_head(htmlspecialchars($user['team_name']), country_flag_link($user['country_name'], $user['country_code'], true), false);
    if (!$user['competing']) {
        message_inline_blue(lang_get('non_competing_user'));
    }
    print_solved_graph($_GET['id']);
    print_solved_challenges($_GET['id']);
    cache_end(CONST_CACHE_NAME_USER . $_GET['id']);
}
foot();
开发者ID:dirvuk,项目名称:mellivora,代码行数:28,代码来源:user.php


注:本文中的message_generic函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。