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


PHP cache_start函数代码示例

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


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

示例1: dynamic_menu_content

function dynamic_menu_content()
{
    $cache_name = user_is_logged_in() ? 'logged_in_' . $_SESSION['class'] : 'guest';
    if (cache_start($cache_name, CONFIG_CACHE_TIME_DYNAMIC, CONST_CACHE_DYNAMIC_MENU_GROUP)) {
        $entries = db_query_fetch_all('SELECT
                title,
                internal_page,
                permalink,
                url,
                visibility
            FROM
                dynamic_menu
            WHERE
                ' . (user_is_logged_in() ? 'min_user_class <= ' . $_SESSION['class'] . ' AND (visibility = "private" OR visibility = "both")' : 'visibility = "public" OR visibility = "both"') . '
            ORDER BY priority DESC');
        foreach ($entries as $entry) {
            echo '
            <li>
                <a href="', $entry['internal_page'] ? CONFIG_SITE_URL . 'content?show=' . $entry['permalink'] : htmlspecialchars($entry['url']), '">', htmlspecialchars($entry['title']), '</a>
            </li>
            ';
        }
        cache_end($cache_name, CONST_CACHE_DYNAMIC_MENU_GROUP);
    }
}
开发者ID:janglapuk,项目名称:mellivora,代码行数:25,代码来源:dynamic.inc.php

示例2: validate_id

<?php

require '../include/mellivora.inc.php';
validate_id($_GET['id']);
head('User details');
if (cache_start('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']));
    section_head(htmlspecialchars($user['team_name']), country_flag_link($user['country_name'], $user['country_code'], true), false);
    if (!$user['competing']) {
        message_inline_blue('This user is listed as a non-competitor.');
    }
    $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
        ORDER BY ca.title ASC', array('user_id' => $_GET['id']));
    $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), '%)';
开发者ID:jpnelson,项目名称:mellivora,代码行数:31,代码来源:user.php

示例3: db_select_one

             $hint1 = db_select_one('purchases', array('*'), array('hid' => $hint['id'], 'uid' => $_SESSION['id']));
             if ($hint1['value'] > 0) {
                 message_inline_yellow('<strong>Hint!</strong> ' . $bbc->parse($hint['body']), false);
             } else {
                 echo '<p><a href="actions/hints.php?action=purchase&id=' . $hint['id'] . '" class="btn btn-xs btn-info">Purchase hint</a><strong> [This hint is available for purchase at ' . $hint['value'] . ' points.]</strong></p>';
             }
         }
     }
     cache_end('hints_challenge_' . $challenge['id']);
 }
 if ($remaining_submissions) {
     if ($challenge['num_submissions'] && !$challenge['automark'] && $challenge['marked']) {
         message_inline_blue('Your submission is awaiting manual marking.');
     }
     // write out files
     if (cache_start('files_' . $challenge['id'], CONFIG_CACHE_TIME_FILES)) {
         $files = db_select_all('files', array('id', 'title', 'size'), array('challenge' => $challenge['id']));
         $filesDuplicate = db_select_all('files', array('id', 'title', 'size'), array('challenge' => $challenge['cloneOf']));
         if (count($files) || count($filesDuplicate)) {
             print_attachments($files);
             print_attachments($filesDuplicate);
         }
         cache_end('files_' . $challenge['id']);
     }
     echo '
     <div class="challenge-submit">
         <form method="post" class="form-flag" action="actions/challenges">
             <textarea name="flag" type="text" class="flag-input form-control" placeholder="Please enter flag for challenge: ', htmlspecialchars($challenge['title']), '"></textarea>
             <input type="hidden" name="challenge" value="', htmlspecialchars($challenge['id']), '" />
             <input type="hidden" name="action" value="submit_flag" />';
     form_xsrf_token();
开发者ID:ZlhlmChZ,项目名称:source-code-mell,代码行数:31,代码来源:challenges.php

示例4: login_session_refresh

<?php

require '../include/mellivora.inc.php';
login_session_refresh();
header('Content-type: application/json');
if (!isset($_GET['view'])) {
    echo json_error(lang_get('please_request_view'));
    exit;
}
if ($_GET['view'] == 'scoreboard') {
    if (cache_start(CONST_CACHE_NAME_SCORES_JSON, CONFIG_CACHE_TIME_SCORES)) {
        json_scoreboard(array_get($_GET, 'user_type'));
        cache_end(CONST_CACHE_NAME_SCORES_JSON);
    }
} else {
    echo json_error(lang_get('please_request_view'));
    exit;
}
开发者ID:dirvuk,项目名称:mellivora,代码行数:18,代码来源:json.php

示例5: validate_id

<?php

require '../include/mellivora.inc.php';
validate_id($_GET['id']);
head('Challenge details');
if (cache_start('challenge_' . $_GET['id'], CONFIG_CACHE_TIME_CHALLENGE)) {
    $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
开发者ID:ZlhlmChZ,项目名称:source-code-mell,代码行数:31,代码来源:challenge.php

示例6: enforce_authentication

<?php

require '../include/mellivora.inc.php';
enforce_authentication();
head('Hints');
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>
开发者ID:ZlhlmChZ,项目名称:source-code-mell,代码行数:31,代码来源:hints.php

示例7: lang_get

 }
 // if this challenge relies on another, and the user hasn't solved that requirement
 if (isset($relies_on) && !$relies_on['has_solved_requirement']) {
     echo '
         <div class="challenge-description relies-on">', lang_get('challenge_relies_on', array('relies_on_link' => '<a href="challenge?id=' . htmlspecialchars($relies_on['id']) . '">' . htmlspecialchars($relies_on['title']) . '</a>', 'relies_on_category_link' => '<a href="challenges?category=' . htmlspecialchars($relies_on['category_id']) . '">' . htmlspecialchars($relies_on['category_title']) . '</a>')), '</div>
     ';
 } else {
     // write out challenge description
     if ($challenge['description']) {
         echo '
         <div class="challenge-description">
             ', $bbc->parse($challenge['description']), '
         </div> <!-- / challenge-description -->';
     }
     // write out hints
     if (cache_start(CONST_CACHE_NAME_CHALLENGE_HINTS . $challenge['id'], CONFIG_CACHE_TIME_HINTS)) {
         $hints = db_select_all('hints', array('body'), array('visible' => 1, 'challenge' => $challenge['id']));
         foreach ($hints as $hint) {
             message_inline_yellow('<strong>Hint!</strong> ' . $bbc->parse($hint['body']), false);
         }
         cache_end(CONST_CACHE_NAME_CHALLENGE_HINTS . $challenge['id']);
     }
     // write out files
     $files = cache_array_get(CONST_CACHE_NAME_FILES . $challenge['id'], CONFIG_CACHE_TIME_FILES);
     if (!is_array($files)) {
         $files = db_select_all('files', array('id', 'title', 'size', 'md5', 'download_key'), array('challenge' => $challenge['id']));
         cache_array_save($files, CONST_CACHE_NAME_FILES . $challenge['id']);
     }
     if (count($files)) {
         print_attachments($files);
     }
开发者ID:dirvuk,项目名称:mellivora,代码行数:31,代码来源:challenges.php

示例8: login_session_refresh

<?php

require '../include/mellivora.inc.php';
login_session_refresh();
if (strlen(array_get($_GET, 'code')) != 2) {
    message_error('Please supply a valid country code');
}
$country = db_select_one('countries', array('id', 'country_name', 'country_code'), array('country_code' => $_GET['code']));
if (!$country) {
    message_error('No country found with that code');
}
head($country['country_name']);
if (cache_start('country_' . $_GET['code'], CONFIG_CACHE_TIME_COUNTRIES)) {
    section_head(htmlspecialchars($country['country_name']) . country_flag_link($country['country_name'], $country['country_code'], true), '', false);
    $scores = db_query_fetch_all('
            SELECT
               u.id AS user_id,
               u.team_name,
               u.competing,
               co.id AS country_id,
               co.country_name,
               co.country_code,
               SUM(c.points) AS score,
               MAX(s.added) AS tiebreaker
            FROM users AS u
            LEFT JOIN countries AS co ON co.id = u.country_id
            LEFT JOIN submissions AS s ON u.id = s.user_id AND s.correct = 1
            LEFT JOIN challenges AS c ON c.id = s.challenge
            WHERE u.competing = 1 AND co.id = :country_id
            GROUP BY u.id
            ORDER BY score DESC, tiebreaker ASC', array('country_id' => $country['id']));
开发者ID:ZlhlmChZ,项目名称:source-code-mell,代码行数:31,代码来源:country.php

示例9: enforce_authentication

<?php

require '../include/mellivora.inc.php';
enforce_authentication();
head(lang_get('hints'));
if (cache_start(CONST_CACHE_NAME_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 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>
开发者ID:janglapuk,项目名称:mellivora,代码行数:31,代码来源:hints.php

示例10: foreach

             <ul>
         ';
         foreach ($files as $file) {
             echo '      <li><a href="download?id=', htmlspecialchars($file['id']), '">', htmlspecialchars($file['title']), '</a> (', bytes_to_pretty_size($file['size']), ')</li>';
         }
         echo '
             </ul>
         </div> <!-- / challenge-files -->';
     }
     cache_end('files_' . $challenge['id']);
 }
 // only show the hints and flag submission form if we're
 // not already correct and if the challenge hasn't expired
 if (!$challenge['correct'] && $time < $challenge['available_until']) {
     // write out hints
     if (cache_start('hints_challenge_' . $challenge['id'], CONFIG_CACHE_TIME_HINTS)) {
         $hints = db_select_all('hints', array('body'), array('visible' => 1, 'challenge' => $challenge['id']));
         foreach ($hints as $hint) {
             message_inline_yellow('<strong>Hint!</strong> ' . $bbc->parse($hint['body']), false);
         }
         cache_end('hints_challenge_' . $challenge['id']);
     }
     if ($remaining_submissions) {
         if ($challenge['num_submissions'] && !$challenge['automark'] && !$challenge['marked']) {
             message_inline_blue('Your submission is awaiting manual marking.');
         }
         echo '
         <div class="challenge-submit">
             <form method="post" class="form-flag" action="actions/challenges">
                 <textarea name="flag" type="text" class="form-control" placeholder="Please enter flag for challenge: ', htmlspecialchars($challenge['title']), '"></textarea>
                 <input type="hidden" name="challenge" value="', htmlspecialchars($challenge['id']), '" />
开发者ID:jpnelson,项目名称:mellivora,代码行数:31,代码来源:challenges.php

示例11: login_session_refresh

<?php

require '../include/mellivora.inc.php';
login_session_refresh();
if (!isset($_GET['show'])) {
    message_error(lang_get('please_request_page'));
}
$menu_data = db_select_one('dynamic_menu', array('internal_page'), array('permalink' => $_GET['show']));
if (!is_valid_id($menu_data['internal_page'])) {
    message_error(lang_get('not_a_valid_link'));
}
$content = db_select_one('dynamic_pages', array('id', 'title', 'body', 'visibility', 'min_user_class'), array('id' => $menu_data['internal_page']));
if ($content['visibility'] == 'private') {
    enforce_authentication($content['min_user_class']);
}
head($content['title']);
if (cache_start($content['id'], CONFIG_CACHE_TIME_DYNAMIC, CONST_CACHE_DYNAMIC_PAGES_GROUP)) {
    section_head($content['title']);
    require CONST_PATH_THIRDPARTY . 'nbbc/nbbc.php';
    $bbc = new BBCode();
    $bbc->SetEnableSmileys(false);
    echo $bbc->parse($content['body']);
    cache_end($content['id'], CONST_CACHE_DYNAMIC_PAGES_GROUP);
}
foot();
开发者ID:dirvuk,项目名称:mellivora,代码行数:25,代码来源:content.php

示例12: validate_id

<?php

require '../include/ctf.inc.php';
validate_id($_GET['id']);
head(lang_get('challenge_details'));
if (cache_start(CONST_CACHE_NAME_CHALLENGE . $_GET['id'], CONFIG_CACHE_TIME_CHALLENGE)) {
    $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 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
开发者ID:azizjonm,项目名称:ctf-engine,代码行数:31,代码来源:challenge.php

示例13: intval

// Load the header content
if(cache_start('header')){

} else {
	include('template/header.php');
	cache_stop();
}
// Get requested blog post, or if none specified get homepage (post_id===0)
$post_id = intval($_GET['post_id']);
$cat_id = intval($_GET['cat_id']);
$cache_id = ($post_id? 'page'. $post_id: ($cat_id? 'category'.$cat_id:'homepage'));

if(!cache_start($cache_id))
{
	if($post_id) {
		load_post($post_id);
	} 
	else {
		list_posts(intval($_GET['cat_id']));
	}
	cache_stop();
}
else {
//	echo "CACHED";
}
if(!cache_start('footer')){
	// Load the footer content 
	include('template/footer.php');
	cache_stop();
}
?>
开发者ID:razialx,项目名称:Stupid-Blog-Example,代码行数:31,代码来源:index-lite.php

示例14: login_session_refresh

<?php

require '../include/mellivora.inc.php';
login_session_refresh();
send_cache_headers('home', CONFIG_CACHE_TIME_HOME);
head('Home');
if (cache_start(CONST_CACHE_NAME_HOME, CONFIG_CACHE_TIME_HOME)) {
    require CONST_PATH_THIRDPARTY . 'nbbc/nbbc.php';
    $bbc = new BBCode();
    $bbc->SetEnableSmileys(false);
    $news = db_query_fetch_all('SELECT * FROM news ORDER BY added DESC');
    foreach ($news as $item) {
        echo '
        <div class="news-container">';
        section_head($item['title']);
        echo '
            <div class="news-body">
                ', $bbc->parse($item['body']), '
            </div>
        </div>
        ';
    }
    cache_end(CONST_CACHE_NAME_HOME);
}
foot();
开发者ID:RowdyChildren,项目名称:49sd-ctf,代码行数:25,代码来源:home.php

示例15: db_select_all

 if ($challenge['description']) {
     echo '
     <div class="challenge-description">
         ', $bbc->parse($challenge['description']), '
     </div> <!-- / challenge-description -->';
 }
 // write out hints
 if (cache_start(CONST_CACHE_NAME_CHALLENGE_HINTS . $challenge['id'], CONFIG_CACHE_TIME_HINTS)) {
     $hints = db_select_all('hints', array('body'), array('visible' => 1, 'challenge' => $challenge['id']));
     foreach ($hints as $hint) {
         message_inline_yellow('<strong>Hint!</strong> ' . $bbc->parse($hint['body']), false);
     }
     cache_end(CONST_CACHE_NAME_CHALLENGE_HINTS . $challenge['id']);
 }
 // write out files
 if (cache_start(CONST_CACHE_NAME_FILES . $challenge['id'], CONFIG_CACHE_TIME_FILES)) {
     $files = db_select_all('files', array('id', 'title', 'size', 'md5'), array('challenge' => $challenge['id']));
     if (count($files)) {
         print_attachments($files);
     }
     cache_end(CONST_CACHE_NAME_FILES . $challenge['id']);
 }
 // only show the hints and flag submission form if we're not already correct and if the challenge hasn't expired
 if (!$challenge['correct_submission_added'] && $time < $challenge['available_until']) {
     if ($remaining_submissions) {
         if ($challenge['num_submissions'] && !$challenge['automark'] && $challenge['marked']) {
             message_inline_blue('Your submission is awaiting manual marking.');
         }
         echo '
         <div class="challenge-submit">
             <form method="post" class="form-flag" action="actions/challenges">
开发者ID:Gustibimo,项目名称:mellivora,代码行数:31,代码来源:challenges.php


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