本文整理汇总了PHP中Profiler::mark方法的典型用法代码示例。如果您正苦于以下问题:PHP Profiler::mark方法的具体用法?PHP Profiler::mark怎么用?PHP Profiler::mark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profiler
的用法示例。
在下文中一共展示了Profiler::mark方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_change
public function action_change()
{
//トークンの生成
$this->action_csrf();
//バリデーション定義
$val = Validation::forge();
$val->add('password', '「現在のパスワード」')->add_rule('required')->add_rule('min_length', 8)->add_rule('max_length', 12);
$val->add('newpassword', '「新しいパスワード」または、「(新)パスワード再入力」')->add_rule('required')->add_rule('min_length', 8)->add_rule('max_length', 12);
$this->action_category();
if (Input::post()) {
if (Security::check_token()) {
if ($val->run()) {
$username = Auth::get_screen_name();
//現在のパスワード
$old_password = Input::post('password');
//新しいパスワード
$new_password = Input::post('newpassword');
//パスワードを変更するメソッド
Auth::change_password($old_password, $new_password, $username);
$this->message = 'パスワードが変更されました。';
$view = View::forge('changepass/ChangePass', $this->data);
$view->set_global('message', $this->message, false);
$view->set_global('error', $this->error, false);
} else {
$this->error = $val->error();
$view = View::forge('changepass/ChangePass', $this->data);
$view->set_global('message', $this->message, false);
$view->set_global('error', $this->error, false);
}
} else {
Profiler::mark('CSRF攻撃');
}
}
return $view;
}
示例2: serve
public function serve($content, $modified = false)
{
$cache_last_modified = $modified ? time() : filemtime($this->path);
$header_modified_since = strtotime(\Input::server('HTTP_IF_MODIFIED_SINCE', 0));
$status = 200;
// Set the response headers for cache etc
$headers = array('Cache-Control' => 'public', 'Last-Modified' => gmdate('D, d M Y H:i:s', $cache_last_modified) . ' GMT', 'Content-Type' => $this->content_type, 'X-UA-Compatible' => 'IE=edge');
// Still call the before method on the controller... is this a good idea? Perhaps not.
/* if (isset($this->request) && $controller = $this->request->controller_instance) {
if (method_exists($controller, 'before')) $controller->before($content);
} */
// Return 304 not modified if the content hasn't changed, but only if the profiler isn't enabled.
if (!\Fuel::$profiling) {
$headers['Content-Length'] = strlen($content);
if ($header_modified_since >= $cache_last_modified) {
header('HTTP/1.1 304 Not Modified');
exit;
}
}
// Send the response
\Response::forge($content, $status, $headers)->send(true);
if (\Fuel::$profiling) {
\Profiler::mark('CMF Cache Served');
}
exit;
}
示例3: __construct
function __construct()
{
if (isset($_GET['debug_profile'])) {
Profiler::mark("Director", "construct");
}
Session::addToArray('history', substr($_SERVER['REQUEST_URI'], strlen(Director::baseURL())));
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Director", "construct");
}
}
示例4: run
/**
* runTask
*
* @param string $name
* @param callable $callback
* @param integer $times
*
* @return $this
*/
protected function run($name, $callback, $times)
{
$this->profiler->mark($name . '-start');
foreach (range(1, $times) as $row) {
call_user_func($callback);
}
$this->profiler->mark($name . '-end');
$time = $this->profiler->getTimeBetween($name . '-start', $name . '-end');
$time = $time * $this->format;
$this->results[$name] = $time;
return $this;
}
示例5: FieldHolder
function FieldHolder()
{
$fieldName = $this->name . 'ID';
$relationName = $this->name;
Profiler::mark("RelatedDataEditor.FieldHolder", "get data");
$record = $this->form->getRecord();
$relatedObject = $record->{$relationName}();
Profiler::unmark("RelatedDataEditor.FieldHolder", "get data");
$this->dropdownField->Name = $this->name . '[ID]';
$this->dropdownField->Value = $record->{$fieldName};
$extraclass = $this->IsNested() ? "nested" : "";
$result .= "<div id=\"{$this->name}\" class=\"{$this->class} groupfield {$extraclass}\" >";
$fieldholder = $this->dropdownField->FieldHolder();
if ($this->showkeydropdown) {
$result .= "<div id=\"{$this->name}_keyholder\" class=\"keyholder\">{$fieldholder}</div>";
if ($this->children) {
$result .= "<img id=\"{$this->name}_loading\" src=\"cms/images/network-save.gif\" style=\"display: none;\" />";
$result .= "<img id=\"{$this->name}_loaded\" src=\"cms/images/alert-good.gif\" style=\"display: none;\" />";
}
} else {
$result .= "<div id=\"{$this->name}_keyholder\" class=\"keyholder\" style=\"display: none\">{$fieldholder}</div>";
}
if ($this->children) {
$result .= "<div id= \"{$this->name}_childrenholder\" class=\"children_holder\">";
foreach ($this->children as $child) {
if (!$child->isComposite()) {
$childFieldName = $child->Name();
$child->Name = $this->name . '[' . $child->Name() . ']';
if ($this->dropdownField->isSelected()) {
$child->Value = $relatedObject->{$childFieldName};
}
$child->setForm($this->form);
$result .= $child->FieldHolder();
} else {
$fs = $child->FieldSet();
foreach ($fs as $subfield) {
$childFieldName = $subfield->Name();
$subfield->Name = $this->name . '[' . $subfield->Name() . ']';
if ($this->dropdownField->isSelected()) {
$subfield->Value = $relatedObject->{$childFieldName};
}
$subfield->setForm($this->form);
}
$result .= $child->FieldHolder();
}
}
$result .= "<div class=\"clear\"> </div>";
$result .= "</div>";
}
$result .= "</div>";
return $result;
}
示例6: runUpdate
/**
* updates database fields
* @param Bool $force - run it, even if it has run already
* @return void
*/
public function runUpdate($force = true)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark('OrderMaker::runUpdate');
}
if (!$this->IsRemoved()) {
$this->checkField("OrderFor");
parent::runUpdate($force);
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark('OrderMaker::runUpdate');
}
}
示例7: runUpdate
/**
* For all modifers with their own database fields, we need to include this...
* It will update each of the fields.
* Within this method, we need to create the methods
* Live{functionName}
* e.g LiveMyField() and LiveMyReduction() in this case...
* The OrderModifier already updates the basic database fields.
* @param Bool $force - run it, even if it has run already
*/
public function runUpdate($force = false)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark('ModifierExample::runUpdate');
}
if (!$this->IsRemoved()) {
$this->checkField("MyField");
$this->checkField("MyReduction");
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark('ModifierExample::runUpdate');
}
parent::runUpdate($force);
}
示例8: action_index
public function action_index()
{
// 実行時間の計測ポイント
Profiler::mark('indexアクションの開始');
$file = DOCROOT . 'show_file.php';
$content = file_get_contents($file);
$title = 'ファイル表示プログラム';
$view = View::forge('showfile');
$view->set('title', $title);
$view->set('content', $content);
// 実行時間の計測ポイント
Profiler::mark('indexアクションの終了');
return $view;
}
示例9: action_index
/**
* Load every call to the API with this method.
*
* @return void
* @access public
*/
public function action_index()
{
// Profile the loader
\Profiler::mark('Start of loader\'s action_index() function');
\Profiler::mark_memory($this, 'Start of loader\'s action_index() function');
// Make sure we aren't processing crap.
if (in_array($this->format, array('csv', 'php', 'serialize'))) {
$this->format = 'json';
}
// For some reason this value is quoted when set to html.
if (\Input::post('format') === '"html"') {
$this->format = 'html';
}
// Cleanse the session to keep things stable.
\Session::destroy();
// For error handling
\Session::set('response_format', $this->format);
// External error processing through Apache
if (\Uri::segment(1) === 'error' && is_numeric(\Uri::segment(2)) && strlen(\Uri::segment(2)) === 3) {
return $this->response(\Utility::format_error(\Uri::segment(2)));
}
// /loader/index/error/404 style (Due to routing)
if (substr_count(\Uri::current(), 'loader/index/error') === 1 && is_numeric(\Uri::segment(4)) && strlen(\Uri::segment(4)) === 3) {
return $this->response(\Utility::format_error(\Uri::segment(4)));
}
// We need a version number
if (empty(\Uri::segment(1)) || \Module::exists(\Uri::segment(1)) === false) {
$error_data = \Utility::format_error(400, \Err::BAD_OR_NO_VERSION, \Lang::get('errors.bad_version'));
return $this->response($error_data, 400);
}
// We need a request.
if (empty(\Input::post()) || \Input::method() !== 'POST') {
$error_data = \Utility::format_error(405, null, \Lang::get('errors.no_request'));
return $this->response($error_data, 405);
}
// Pass the request to the proper API version request handler. (Module)
if (!empty(\Input::post())) {
\Module::load(\Uri::segment(1));
$response = \Request::forge(\Uri::segment(1) . '/index', false)->execute()->response->body;
// HTML only Data Calls
if (is_string($response)) {
return $this->response($response, 200);
}
return $this->response($response[0], $response[1]);
}
}
示例10: get
public function get($url)
{
if (\Fuel::$profiling) {
\Profiler::mark('CMF Cache Start (auto)');
}
$this->request = \Request::active();
$this->path = APPPATH . 'cache/pages/' . \CMF\Cache::uriCacheKey($url) . '.cache';
if (file_exists($this->path)) {
$contents = unserialize(file_get_contents($this->path));
// Check the files first
$cache_modified = filemtime($this->path);
foreach ($contents['files'] as $file) {
$file = PROJECTROOT . $file;
if (!file_exists($file) || filemtime($file) > $cache_modified) {
$this->startListeners();
return false;
}
}
// Now check the last modified / record counts from the DB
if (!empty($contents['sql'])) {
$result = \DB::query($contents['sql'])->execute()->as_array();
$result = $result[0];
if ($result['count'] !== $contents['count'] || strtotime($result['updated_at']) > $contents['updated_at']) {
$this->startListeners();
return false;
}
}
// See if the cache defines a content type
if (isset($contents['content-type'])) {
$this->content_type = $contents['content-type'];
}
// We are home and dry - the cache is completely valid.
// Replicate any logs that were made in the original request
\CMF\Log::addMultiple($contents['logs_made']);
// Ok, now we can serve the cache, finally!!
// We process the cached content to find and replace any areas that shouldn't be cached
return \CMF\Cache::addNoCacheAreas($contents['nocache'], $contents['content'], array('template' => @$contents['template'], 'module' => @$contents['module']));
}
// If we've arrived here, we need to start listening for queries and assets
$this->startListeners();
return false;
}
示例11: stageChildren
/**
* Overridden to load all children from Cmis instead of this node
* directly
*
* @param boolean $showAll
* @return DataObjectSet
*/
public function stageChildren($showAll = false)
{
if (!$this->ID) {
return DataObject::get('CmisContentSource');
}
$repo = $this->source->getRemoteRepository();
$children = ArrayList::create();
if ($repo->isConnected()) {
if (isset($_GET['debug_profile'])) {
Profiler::mark("CmisContentItem", "getChildren");
}
$childItems = $repo->getChildren($this->cmisObject);
if ($childItems) {
foreach ($childItems as $child) {
$item = new CmisContentItem($this->source, $child);
$children->push($item);
}
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark("CmisContentItem", "getChildren");
}
}
return $children;
}
示例12: includeInHTML
/**
* Update the given HTML content with the appropriate include tags for the registered
* requirements.
* @todo Calculate $prefix properly
*/
static function includeInHTML($templateFile, $content)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark("Requirements::includeInHTML");
}
if (strpos($content, '</head') !== false && (Requirements::$javascript || Requirements::$css || Requirements::$customScript || Requirements::$customHeadTags)) {
$prefix = "";
$requirements = '';
foreach (array_diff_key(self::$javascript, self::$blocked) as $file => $dummy) {
if (substr($file, 0, 7) == 'http://' || Director::fileExists($file)) {
$requirements .= "<script type=\"text/javascript\" src=\"{$prefix}{$file}\"></script>\n";
}
}
if (self::$customScript) {
$requirements .= "<script type=\"text/javascript\">\n//<![CDATA[\n";
foreach (array_diff_key(self::$customScript, self::$blocked) as $script) {
$requirements .= "{$script}\n";
}
$requirements .= "\n//]]>\n</script>\n";
}
foreach (array_diff_key(self::$css, self::$blocked) as $file => $params) {
if (Director::fileExists($file)) {
$media = isset($params['media']) ? " media=\"{$params['media']}\"" : "";
$requirements .= "<link rel=\"stylesheet\" type=\"text/css\"{$media} href=\"{$prefix}{$file}\" />\n";
}
}
foreach (array_diff_key(self::$customCSS, self::$blocked) as $css) {
$requirements .= "<style type=\"text/css\">\n{$css}\n</style>\n";
}
$requirements .= self::$customHeadTags;
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Requirements::includeInHTML");
}
return eregi_replace("(</head[^>]*>)", $requirements . "\\1", $content);
} else {
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Requirements::includeInHTML");
}
return $content;
}
}
示例13: process
/**
* The process() method handles the "meat" of the template processing.
*/
public function process($item) {
SSViewer::$topLevel[] = $item;
if(isset($this->chosenTemplates['main'])) {
$template = $this->chosenTemplates['main'];
} else {
$template = $this->chosenTemplates[ reset($dummy = array_keys($this->chosenTemplates)) ];
}
if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process", " for $template");
$cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\','/',':'),'.',realpath($template));
$lastEdited = filemtime($template);
if(!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
if(isset($_GET['debug_profile'])) Profiler::mark("SSViewer::process - compile", " for $template");
$content = file_get_contents($template);
$content = SSViewer::parseTemplateContent($content, $template);
$fh = fopen($cacheFile,'w');
fwrite($fh, $content);
fclose($fh);
if(isset($_GET['debug_profile'])) Profiler::unmark("SSViewer::process - compile", " for $template");
}
if(isset($_GET['showtemplate']) && !Director::isLive()) {
$lines = file($cacheFile);
echo "<h2>Template: $cacheFile</h2>";
echo "<pre>";
foreach($lines as $num => $line) {
echo str_pad($num+1,5) . htmlentities($line);
}
echo "</pre>";
}
foreach(array('Content', 'Layout') as $subtemplate) {
if(isset($this->chosenTemplates[$subtemplate])) {
$subtemplateViewer = new SSViewer($this->chosenTemplates[$subtemplate]);
$item = $item->customise(array(
$subtemplate => $subtemplateViewer->process($item)
));
}
}
$itemStack = array();
$val = "";
include($cacheFile);
$output = $val;
$output = Requirements::includeInHTML($template, $output);
array_pop(SSViewer::$topLevel);
if(isset($_GET['debug_profile'])) Profiler::unmark("SSViewer::process", " for $template");
// If we have our crazy base tag, then fix # links referencing the current page.
if(strpos($output, '<base') !== false) {
$thisURLRelativeToBase = Director::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI']));
$output = preg_replace('/(<a[^>+]href *= *")#/i', '\\1' . $thisURLRelativeToBase . '#', $output);
}
return $output;
}
示例14: stageChildren
/**
* Overridden to load all children from Matrix. For now we're ignoring
* the $showAll param - we have a separate 'dependentChildren' method
* to specifically handle dependent and non-dependent children
*
* @param boolean $showAll
* @return ArrayList
*/
public function stageChildren($showAll = false)
{
if (!$this->ID) {
return MatrixContentSource::get();
}
if (!$this->objChildren) {
$this->objChildren = new ArrayList();
// For the first batch, just get all the immediate children of the
// top level
$repo = $this->source->getRemoteRepository();
if ($repo->isConnected()) {
if (isset($_GET['debug_profile'])) {
Profiler::mark("MatrixContentItem", "getChildren");
}
if (!isset($this->remoteProperties['id'])) {
// for some reason the call failed!
return $this->objChildren;
}
$childItems = $repo->getChildren(array('id' => $this->remoteProperties['id'], 'depth' => 1));
if (isset($_GET['debug_profile'])) {
Profiler::unmark("MatrixContentItem", "getChildren");
}
// make sure that there's no errors!!
if (!isset($childItems->error)) {
if (isset($_GET['debug_profile'])) {
Profiler::mark("MatrixContentItem", "loadChildren");
}
// means there weren't any children of this asset
foreach ($childItems as $childId => $properties) {
$item = $this->source->getObject($properties->id);
if (isset($properties->LinkType)) {
$item->ShowInMenus = true;
}
$this->objChildren->push($item);
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark("MatrixContentItem", "loadChildren");
}
}
}
}
return $this->objChildren;
}
示例15: silverstripe_main
function silverstripe_main($chain)
{
global $token;
if (isset($_GET['flush']) && !$token->tokenProvided()) {
unset($_GET['flush']);
} else {
$chain->setSuppression(false);
}
/**
* Include Sapphire's core code
*/
require_once "core/Core.php";
if (function_exists('mb_http_output')) {
mb_http_output('UTF-8');
mb_internal_encoding('UTF-8');
}
Session::start();
if (isset($_GET['debug_profile'])) {
Profiler::init();
Profiler::mark('all_execution');
Profiler::mark('main.php init');
}
// Connect to database
require_once "core/model/DB.php";
global $databaseConfig;
if (isset($_GET['debug_profile'])) {
Profiler::mark('DB::connect');
}
if ($databaseConfig) {
DB::connect($databaseConfig);
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark('DB::connect');
}
if ($token->parameterProvided() && !$token->tokenProvided()) {
// First, check if we're in dev mode, or the database doesn't have any security data
$canFlush = Director::isDev() || !Security::database_is_ready();
// Otherwise, we start up the session if needed, then check for admin
if (!$canFlush) {
if (!isset($_SESSION) && (isset($_COOKIE[session_name()]) || isset($_REQUEST[session_name()]))) {
Session::start();
}
if (Permission::check('ADMIN')) {
$canFlush = true;
} else {
$loginPage = Director::absoluteURL('Security/login');
$loginPage .= "?BackURL=" . urlencode($_SERVER['REQUEST_URI']);
header('location: ' . $loginPage, true, 302);
die;
}
}
// And if we can flush, reload with an authority token
if ($canFlush) {
$token->reloadWithToken();
}
}
}