本文整理汇总了PHP中Kofradia\DB::getProfiler方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getProfiler方法的具体用法?PHP DB::getProfiler怎么用?PHP DB::getProfiler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kofradia\DB
的用法示例。
在下文中一共展示了DB::getProfiler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
define("BASE_LOADED", true);
// starter utdata buffer
ob_start();
// hent essenntials
require "essentials.php";
ess::$b->base = $this;
// kjør scheduler
if (!MAIN_SERVER) {
$this->scheduler();
}
ess::$b->dt("load_es-gu_pre");
// hent inn brukerinformasjon
login::init();
ess::$b->dt("post");
// sjekk ssl
$this->check_ssl();
// brukerstæsj
if (login::$logged_in) {
$this->load_user_stuff();
} else {
$this->update_anon_stats();
}
// logg visning
$this->log_request();
// sjekk referer
$this->check_referer();
define("SCRIPT_TIME_HALF", microtime(true) - SCRIPT_START);
$profiler = \Kofradia\DB::getProfiler();
define("QUERIES_TIME_HALF", $profiler ? $profiler->time : null);
define("QUERIES_NUM_HALF", $profiler ? $profiler->num : null);
$this->load_config();
ess::$b->dt("base_loaded");
}
示例2: set_headers
/** Sett headers */
public static function set_headers()
{
// kan ikke sende headers hvis headers allerede er sendt
if (headers_sent()) {
return;
}
// sett riktig retur
self::type_header(self::$type);
// sett script tid
if (defined("SCRIPT_START")) {
header("X-HSW-Time: " . round(microtime(true) - SCRIPT_START, 4));
}
// sett database info
if ($profiler = \Kofradia\DB::getProfiler()) {
header("X-HSW-Queries: " . $profiler->num);
header("X-HSW-Queries-Time: " . round($profiler->time, 4));
}
}
示例3: postParse
/**
* Parse innhold etter det er generert og gjør siste endringer
*
* Legger til meldinger, brukerlenker m.v.
*
* Legger også til debuginfo
*
* @param string
* @return string
*/
public function postParse($content)
{
\ess::$b->dt("postParse start");
// sjekk om betingelsene er oppdatert
if (login::$logged_in && login::$user->data['u_tos_version'] != game::$settings['tos_version']['value'] && !defined("TOS_MESSAGE")) {
define("TOS_MESSAGE", true);
$this->add_message('<b>Betingelser oppdatert -</b> Du har ikke lest gjennom de nyeste <a href="' . ess::$s['rpath'] . '/betingelser">betingelsene</a>! Ditt videre bruk betyr at du samtykker i disse betingelsene.', "error");
}
// informasjonsmeldinger
$msgs = $this->messages->getBoxes();
if (!preg_match_all("~<boxes( (-?\\d+))? />~", $content, $matches, PREG_SET_ORDER)) {
throw new \RuntimeException("Missing boxes-element from template.");
}
$match = '';
$match_id = null;
foreach ($matches as $m) {
$id = isset($m[2]) ? (int) $m[2] : 0;
if ($match_id === null || $id > $match_id) {
$match = $m[0];
}
}
$content = preg_replace("~" . preg_quote($match, "~") . "~", $msgs, $content, 1);
$content = preg_replace("~<boxes( (-?\\d+))? />~", "", $content);
// gå gjennom HTML og sjekk for brukerlinker (<user../>) osv. og vis innholdet
$content = parse_html($content);
if (defined("SHOW_QUERIES_INFO")) {
$profiler = \Kofradia\DB::getProfiler();
$db = '';
if ($profiler && count($profiler->statements) > 0) {
$statements = $profiler->statements;
$x = 0;
foreach (array_keys($statements[0]) as $key) {
$x = max($x, strlen($key));
}
$newlist = array();
foreach ($statements as $statement) {
$new = array();
foreach ($statement as $key => $row) {
$new[str_pad($key, $x)] = $row;
}
$newlist[] = $new;
}
$db = '<br />DATABASE<br />' . htmlspecialchars(print_r($newlist, true));
}
$content .= '
<a href="javascript:void(0)" onclick="this.nextSibling.style.display=\'block\'">Debug info</a><div style="display: none"><br />
<pre>
GET<br />' . htmlspecialchars(print_r($_GET, true)) . '<br />
POST<br />' . htmlspecialchars(print_r($_POST, true)) . $db . '
</pre>
</div>';
}
\ess::$b->dt('postParse end');
return $content;
}
示例4: action_profilerinfo
public function action_profilerinfo()
{
$profiler = \Kofradia\DB::getProfiler();
return \Kofradia\View::forgeTwig('templates/helpers/profiler', array("script_time" => round(microtime(true) - SCRIPT_START - $profiler->time, 4), "database_time" => round($profiler->time, 4), "num_queries" => $profiler->num));
}
示例5: generate_page
//.........这里部分代码省略.........
<p id="default_profilbilde">
<span id="default_profilbilde_wrap">
<a href="' . ess::$s['relative_path'] . '/min_side?' . (!login::$user->player->active ? "up_id=" . login::$user->player->id . '&' : '') . 'a=profil&b=profilbilde" class="profile_image_edit"><img src="/static/icon/image.png" /> endre</a>
<a href="' . ess::$s['relative_path'] . '/p/' . login::$user->player->data['up_name'] . '"><img src="' . htmlspecialchars(login::$user->player->get_profile_image()) . '" alt="Ditt profilbilde" class="profile_image" /></a>
</span>
</p>
<p id="default_playername">' . game::profile_link() . '</p>' . self::get_oppdrag_status() . '
</div>
<div id="default_header_subline">
<p id="server_klokka"><span>' . self::$date_now->format(date::FORMAT_WEEKDAY) . ' ' . self::$date_now->format(date::FORMAT_NOTIME) . ' - ' . self::$date_now->format("H:i:s") . '</span></p>
<div id="pm_new">' . (self::$num_pm > 0 ? '<p class="notification_box"><a href="' . ess::$s['relative_path'] . '/innboks"><b>' . self::$num_pm . ' ' . fword("ny</b> melding", "nye</b> meldinger", self::$num_pm) . '</a></p>' : '') . '</div>
<div id="log_new">' . (self::$num_log > 0 ? '<p class="notification_box"><a href="' . ess::$s['relative_path'] . '/min_side?log"><b>' . self::$num_log . ' ' . fword("ny</b> hendelse", "nye</b> hendelser", self::$num_log) . '</a></p>' : '') . '</div>';
if (login::$user->data['u_log_crew_new'] > 0 && isset(login::$extended_access)) {
echo '
<p class="notification_box"><a href="' . ess::$s['relative_path'] . '/min_side?u&a=crewlog"><b>' . login::$user->data['u_log_crew_new'] . '</b> ' . fword("ny hendelse som crew", "nye hendelser som crew", login::$user->data['u_log_crew_new']) . '</a></p>';
}
if (!self::$locked) {
echo '
<div id="def_ui2">
<p>' . login::$user->player->getRank()->getName() . '</p>
<p><span class="farge">Sted: </span> <span id="status_bydel">' . game::$bydeler[login::$user->player->data['up_b_id']]['name'] . '</span></p>
<p><span class="farge">Har ute</span> <span id="status_cash">' . game::format_cash(login::$user->player->data['up_cash']) . '</span></p>
<p><span class="farge">Plassering: </span> nr. <span id="status_rankpos">' . login::$user->player->data['upr_rank_pos'] . '</span></p>
</div>';
}
echo '
</div>
</div>
<div id="default_left">';
if (!login::$user->player->active) {
echo '
<div id="default_info_dead">
<a href="' . ess::$s['relative_path'] . '/lock?f=player">' . (login::$user->player->data['up_deactivated_dead'] == 2 ? '
<span>Din spiller blødde ihjel pga. lite energi.</span>' : (login::$user->player->data['up_deactivated_dead'] ? '
<span>Din spiller har blitt drept.</span>' : '
<span>Din spiller er deaktivert.</span>')) . '
<span class="link">Ny spiller »</span>
</a>
</div>';
}
echo '
<nav>' . kf_menu::build_menu() . '
</nav>
</div>';
if (defined("DISABLE_RIGHT_COL")) {
$content_right = '';
} else {
$content_right = ess::$b->page->generate_content_right();
# self::$locked ..?
}
echo '
<div id="default_main">';
if ($content_right) {
echo '
<div id="default_right">' . $content_right . '</div>';
}
echo '
<div id="default_content_wrap"' . (!$content_right ? ' class="noright"' : '') . '>' . self::get_status_bars() . '
<section id="default_content">' . ess::$b->page->content . '</section>
</div>
</div>
<div id="default_bottom_1">
<p><a href="/">Kofradia</a> © - Beskyttet av <a href="http://www.lovdata.no/all/nl-19610512-002.html" target="_blank">åndsverkloven</a> - Utviklet av <a href="http://www.henrist.net/" target="_blank">Henrik Steen</a></p>
<p><a href="' . ess::$s['relative_path'] . '/betingelser">Betingelser for bruk</a> - Besøk <a href="irc://irc.quakenet.org/kofradia" target="_blank">#Kofradia</a> på QuakeNet<!-- <a href="' . ess::$s['relative_path'] . '/forum/topic?id=85">(Hjelp)</a>--> - <a href="' . ess::$s['relative_path'] . '/credits">Takk til</a></p>
</div>
<div id="default_bottom_2">';
$profiler = \Kofradia\DB::getProfiler();
echo '
<p>Script: ' . round(microtime(true) - SCRIPT_START - $profiler->time, 4) . ' sek - Database: ' . round($profiler->time, 4) . ' sek (' . $profiler->num . ' spørring' . ($profiler->num == 1 ? '' : 'er') . ')<span id="js_time"></span></p>';
$revision = self::get_revision_info();
if ($revision) {
echo '
<p>Versjon <a href="https://github.com/hswno/kofradia/commit/' . $revision['commit'] . '" title="' . htmlspecialchars($revision['message']) . '">' . mb_substr($revision['commit'], 0, 8) . '</a> oppdatert ' . ess::$b->date->get($revision['date'])->format() . '. <a href="&rpath;/github">Logg</a></p>';
} else {
echo '
<p>Versjonsinformasjon er utilgjengelig.</p>';
}
echo '
<p>Tid og dato ved visning: <b>' . self::$date_now->format(date::FORMAT_SEC) . '</b>.</p>
</div>' . ess::$b->page->body_end;
// debug time
/*$time = SCRIPT_START;
ess::$b->dt("end");
$dt = 'start';
foreach (ess::$b->time_debug as $row)
{
$dt .= ' -> '.round(($row[1]-$time)*1000, 2).' -> '.$row[0];
$time = $row[1];
}*/
/*if (MAIN_SERVER)
{
$text = ess::$b->date->get()->format("Y-m-d\tH:i:s\t")."{$_SERVER['REMOTE_ADDR']}\t{$_SERVER['REQUEST_METHOD']}\t{$_SERVER['REQUEST_URI']}\t".login::$user->player->id."\t".login::$user->player->data['up_name']."\t".round(microtime(true)-SCRIPT_START-ess::$b->db->time, 4)."\t".round(ess::$b->db->time, 4)."\t".ess::$b->db->queries."\t".str_replace(" -> ", "\t", $dt)."\n";
@file_put_contents("/home/smafia/debugtime.log", $text, FILE_APPEND);
}*/
/*echo '
<!-- '.$dt.' -->*/
echo '
</body>
</html>';
}