本文整理汇总了PHP中mtrace函数的典型用法代码示例。如果您正苦于以下问题:PHP mtrace函数的具体用法?PHP mtrace怎么用?PHP mtrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mtrace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute.
*/
public function execute()
{
mtrace('Sync cohort roles...');
$result = api::sync_all_cohort_roles();
mtrace('Added ' . count($result['rolesadded']));
mtrace('Removed ' . count($result['rolesremoved']));
}
示例2: user_mnet_hosts_set_access
/**
* set or unset an access to some peer
* @param int $userid
* @param bool $access true or false
* @param string $wwwroot optional host root to give acces to. the access filed name is computed from the wwwroot url
*/
function user_mnet_hosts_set_access($userid, $access, $wwwroot = null)
{
global $CFG, $DB;
if (!$wwwroot) {
$wwwroot = $CFG->wwwroot;
}
$accesskey = user_mnet_hosts_make_accesskey($wwwroot, true);
if (!($field = $DB->get_record('user_info_field', array('shortname' => $accesskey)))) {
// Try to setup install if results not having done before.
if ($wwwroot == $CFG->wwwroot) {
require_once $CFG->dirroot . '/blocks/user_mnet_hosts/db/install.php';
xmldb_block_user_mnet_hosts_install();
mtrace("Second chance {$accesskey} ");
$field = $DB->get_record('user_info_field', array('shortname' => $accesskey));
} else {
return false;
}
}
if ($data = $DB->get_record('user_info_data', array('userid' => $userid, 'fieldid' => $field->id))) {
$data->data = $access;
$DB->update_record('user_info_data', $data);
} else {
$data = new StdClass();
$data->userid = $userid;
$data->fieldid = $field->id;
$data->data = $access;
$DB->insert_record('user_info_data', $data);
}
}
示例3: execute
public function execute()
{
include_once $CFG->dirroot . '/local/enrolmentreminder/lib.php';
mtrace('running enrolment reminders scheduled task');
local_enrolmentreminder_cron();
set_config('lastcron', time(), 'local_enrolmentreminder');
}
示例4: execute
/**
* Function to be run periodically according to the moodle cron
* This function searches for things that need to be done, such
* as sending out mail, toggling flags etc ...
*
* Runs any automatically scheduled reports weekly or monthly.
*
* @return boolean
*/
public function execute()
{
global $CFG, $DB;
require_once dirname(__FILE__) . '/../../locallib.php';
$timenow = time();
list($startofthisweek, $startoflastweek) = report_customsql_get_week_starts($timenow);
list($startofthismonth) = report_customsql_get_month_starts($timenow);
mtrace("... Looking for old temp CSV files to delete.");
$numdeleted = report_customsql_delete_old_temp_files($startoflastweek);
if ($numdeleted) {
mtrace("... {$numdeleted} old temporary files deleted.");
}
// Get daily scheduled reports.
$dailyreportstorun = report_customsql_get_ready_to_run_daily_reports($timenow);
// Get weekly and monthly scheduled reports.
$scheduledreportstorun = $DB->get_records_select('report_customsql_queries', "(runable = 'weekly' AND lastrun < :startofthisweek) OR\n (runable = 'monthly' AND lastrun < :startofthismonth)", array('startofthisweek' => $startofthisweek, 'startofthismonth' => $startofthismonth), 'lastrun');
// All reports ready to run.
$reportstorun = array_merge($dailyreportstorun, $scheduledreportstorun);
foreach ($reportstorun as $report) {
mtrace("... Running report " . strip_tags($report->displayname));
try {
report_customsql_generate_csv($report, $timenow);
} catch (\Exception $e) {
mtrace("... REPORT FAILED " . $e->getMessage());
}
}
}
示例5: filter
function filter($text, array $options = array())
{
global $CFG;
if (!is_string($text) or empty($text)) {
// non string data can not be filtered anyway
return $text;
}
if (stripos($text, '</a>') === false) {
// performance shortcut - all regexes bellow end with the </a> tag,
// if not present nothing can match
return $text;
}
$newtext = $text;
// we need to return the original value if regex fails!
/**
* TODO
* The following doesn't work correctly; we get an array with only letters:
*
* [0]=>"<a href="http://link.mediacore.tv/media/video">link</a>",
* [1]=>"n",
* [2]=>"N";
*
* This effects the actual filter function below.
*
*/
$search = '/<a\\s[^>]+http:\\/\\/([0-9A-Za-z])+\\.mediacore\\.tv\\/([0-9A-Za-z])[^>]+>([0-9A-Za-z])+[^>]+>/';
$newtext = preg_replace_callback($search, 'filter_mediacorefilter_callback', $newtext);
if (empty($newtext) or $newtext === $text) {
// error or not filtered
mtrace('link empty');
unset($newtext);
return $text;
}
return $newtext;
}
示例6: report_customsql_cron
/**
* Cron that runs any automatically scheduled reports weekly or monthly.
*/
function report_customsql_cron()
{
global $CFG;
$timenow = time();
if (!empty($CFG->reportcustomsqlmaxruntime)) {
$timestop = $timenow + $CFG->reportcustomsqlmaxruntime;
} else {
$timestop = $timenow + 180;
// Three minutes.
}
list($startofthisweek, $startoflastweek) = report_customsql_get_week_starts($timenow);
list($startofthismonth) = report_customsql_get_month_starts($timenow);
mtrace("... Looking for old temp CSV files to delete.");
$numdeleted = report_customsql_delete_old_temp_files($startoflastweek);
if ($numdeleted) {
mtrace("... {$numdeleted} files deleted.");
}
$reportstorun = get_records_select('report_customsql_queries', "(runable = 'weekly' AND lastrun < {$startofthisweek}) OR\n (runable = 'monthly' AND lastrun < {$startofthismonth})", 'lastrun');
if (empty($reportstorun)) {
return;
}
while (!empty($reportstorun) && time() < $timestop) {
$report = array_shift($reportstorun);
mtrace("... Running report " . strip_tags($report->displayname));
try {
report_customsql_generate_csv($report, $timenow);
} catch (Exception $e) {
mtrace("... REPORT FAILED " . $e->getMessage());
}
}
}
示例7: get_text_for_indexing_doc
/**
* MS Word extractor
* @param object $resource
* @uses CFG, USER
*/
function get_text_for_indexing_doc(&$resource)
{
global $CFG, $USER;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) {
return;
}
$moodleroot = @$CFG->block_search_usemoodleroot ? "{$CFG->dirroot}/" : '';
// just call pdftotext over stdout and capture the output
if (!empty($CFG->block_search_word_to_text_cmd)) {
if (!file_exists("{$moodleroot}{$CFG->block_search_word_to_text_cmd}")) {
mtrace('Error with MSWord to text converter command : exectuable not found.');
} else {
$file = escapeshellarg($CFG->dataroot . '/' . $resource->course . '/' . $resource->reference);
$command = trim($CFG->block_search_word_to_text_cmd);
$text_converter_cmd = "{$moodleroot}{$command} {$file}";
if ($CFG->block_search_word_to_text_env) {
putenv($CFG->block_search_word_to_text_env);
}
mtrace("Executing : {$text_converter_cmd}");
$result = shell_exec($text_converter_cmd);
if ($result) {
return mb_convert_encoding($result, 'UTF8', 'auto');
} else {
mtrace('Error with MSWord to text converter command : execution failed. ');
return '';
}
}
} else {
mtrace('Error with MSWord to text converter command : command not set up. Execute once search block configuration.');
return '';
}
}
示例8: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG;
$timenow = time();
// Run stats as at the end because they are known to take very long time on large sites.
if (!empty($CFG->enablestats) and empty($CFG->disablestatsprocessing)) {
require_once $CFG->dirroot . '/lib/statslib.php';
// Check we're not before our runtime.
$timetocheck = stats_get_base_daily() + $CFG->statsruntimestarthour * 60 * 60 + $CFG->statsruntimestartminute * 60;
if ($timenow > $timetocheck) {
// Process configured number of days as max (defaulting to 31).
$maxdays = empty($CFG->statsruntimedays) ? 31 : abs($CFG->statsruntimedays);
if (stats_cron_daily($maxdays)) {
if (stats_cron_weekly()) {
if (stats_cron_monthly()) {
stats_clean_old();
}
}
}
\core_php_time_limit::raise();
} else {
mtrace('Next stats run after:' . userdate($timetocheck));
}
}
}
示例9: cron
/**
* Automatically update the registration on all hubs
*/
public function cron()
{
global $CFG;
if (extension_loaded('xmlrpc')) {
//check if the last registration cron update was less than a week ago
$lastcron = get_config('registration', 'crontime');
if ($lastcron === false or $lastcron < strtotime("-7 day")) {
//set to a week, see MDL-23704
$function = 'hub_update_site_info';
require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php";
//update all hub where the site is registered on
$hubs = $this->get_registered_on_hubs();
foreach ($hubs as $hub) {
//update the registration
$siteinfo = $this->get_site_info($hub->huburl);
$params = array('siteinfo' => $siteinfo);
$serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
try {
$result = $xmlrpcclient->call($function, $params);
mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
} catch (Exception $e) {
$errorparam = new stdClass();
$errorparam->errormessage = $e->getMessage();
$errorparam->hubname = $hub->hubname;
mtrace(get_string('errorcron', 'hub', $errorparam));
}
}
set_config('crontime', time(), 'registration');
}
} else {
mtrace(get_string('errorcronnoxmlrpc', 'hub'));
}
}
示例10: get_text_for_indexing_pdf
/**
* @param object $resource
* @uses CFG, USER
*/
function get_text_for_indexing_pdf(&$resource)
{
global $CFG, $USER;
// SECURITY : do not allow non admin execute anything on system !!
if (!isadmin($USER->id)) {
return;
}
// adds moodle root switch if none was defined
if (!isset($CFG->block_search_usemoodleroot)) {
set_config('block_search_usemoodleroot', 1);
}
$moodleroot = $CFG->block_search_usemoodleroot ? "{$CFG->dirroot}/" : '';
// just call pdftotext over stdout and capture the output
if (!empty($CFG->block_search_pdf_to_text_cmd)) {
preg_match("/^\\S+/", $CFG->block_search_pdf_to_text_cmd, $matches);
if (!file_exists("{$moodleroot}{$matches[0]}")) {
mtrace('Error with pdf to text converter command : executable not found at ' . $moodleroot . $matches[0]);
} else {
$file = escapeshellarg($CFG->dataroot . '/' . $resource->course . '/' . $resource->reference);
$command = trim($CFG->block_search_pdf_to_text_cmd);
$text_converter_cmd = "{$moodleroot}{$command} {$file} -";
$result = shell_exec($text_converter_cmd);
if ($result) {
return $result;
} else {
mtrace('Error with pdf to text converter command : execution failed for ' . $text_converter_cmd . '. Check for execution permission on pdf converter executable.');
return '';
}
}
} else {
mtrace('Error with pdf to text converter command : command not set up. Execute once search block configuration.');
return '';
}
}
示例11: authenticate
public function authenticate($userId, $challenge, $response)
{
Manager::logMessage("[LOGIN] Authenticating {$userId} MD5");
$login = NULL;
try {
$user = Manager::getModelMAD('user');
$user->getByLogin($userId);
mtrace("Authenticate userID = {$userId}");
if ($user->validatePasswordMD5($challenge, $response)) {
$profile = $user->getProfileAtual();
$user->getByProfile($profile);
$login = new MLogin($user);
if (Manager::getOptions("dbsession")) {
$session = Manager::getModelMAD('session');
$session->lastAccess($login);
$session->registerIn($login);
}
$this->setLogin($login);
$this->setLoginLogUserId($user->getId());
$this->setLoginLog($login->getLogin());
Manager::logMessage("[LOGIN] Authenticated {$userId} MD5");
return true;
} else {
Manager::logMessage("[LOGIN] {$userId} NOT Authenticated MD5");
}
} catch (Exception $e) {
Manager::logMessage("[LOGIN] {$userId} NOT Authenticated MD5 - " . $e->getMessage());
}
return false;
}
示例12: execute
/**
* Performs the task
*
* @throws moodle_exception on an error (the job will be retried)
*/
public function execute()
{
global $DB;
$subcourses = $DB->get_records("subcourse", null, "", "id, course, refcourse");
if (empty($subcourses)) {
return;
}
$updatedids = array();
foreach ($subcourses as $subcourse) {
if (empty($subcourse->refcourse)) {
mtrace("Subcourse {$subcourse->id}: no referenced course configured ... skipped");
continue;
}
mtrace("Subcourse {$subcourse->id}: fetching grades from course {$subcourse->refcourse} to course {$subcourse->course} ... ", "");
$result = subcourse_grades_update($subcourse->course, $subcourse->id, $subcourse->refcourse);
if ($result == GRADE_UPDATE_OK) {
$updatedids[] = $subcourse->id;
mtrace("ok");
} else {
mtrace("failed with error code " . $result);
}
}
if (!empty($updatedids)) {
subcourse_update_timefetched($updatedids);
}
}
示例13: cron
/**
* Automatically update the registration on all hubs
*/
public function cron()
{
global $CFG;
if (extension_loaded('xmlrpc')) {
$function = 'hub_update_site_info';
require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php";
// Update all hubs where the site is registered.
$hubs = $this->get_registered_on_hubs();
if (empty($hubs)) {
mtrace(get_string('registrationwarning', 'admin'));
}
foreach ($hubs as $hub) {
// Update the registration.
$siteinfo = $this->get_site_info($hub->huburl);
$params = array('siteinfo' => $siteinfo);
$serverurl = $hub->huburl . "/local/hub/webservice/webservices.php";
$xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token);
try {
$result = $xmlrpcclient->call($function, $params);
$this->update_registeredhub($hub);
// To update timemodified.
mtrace(get_string('siteupdatedcron', 'hub', $hub->hubname));
} catch (Exception $e) {
$errorparam = new stdClass();
$errorparam->errormessage = $e->getMessage();
$errorparam->hubname = $hub->hubname;
mtrace(get_string('errorcron', 'hub', $errorparam));
}
}
} else {
mtrace(get_string('errorcronnoxmlrpc', 'hub'));
}
}
示例14: tool_qeupgradehelper_process
/**
* This function does the cron process within the time range according to settings.
*/
function tool_qeupgradehelper_process($settings)
{
global $CFG;
require_once dirname(__FILE__) . '/locallib.php';
if (!tool_qeupgradehelper_is_upgraded()) {
mtrace('qeupgradehelper: site not yet upgraded. Doing nothing.');
return;
}
require_once dirname(__FILE__) . '/afterupgradelib.php';
$hour = (int) date('H');
if ($hour < $settings->starthour || $hour >= $settings->stophour) {
mtrace('qeupgradehelper: not between starthour and stophour, so doing nothing (hour = ' . $hour . ').');
return;
}
$stoptime = time() + $settings->procesingtime;
mtrace('qeupgradehelper: processing ...');
while (time() < $stoptime) {
$quiz = tool_qeupgradehelper_get_quiz_for_upgrade();
if (!$quiz) {
mtrace('qeupgradehelper: No more quizzes to process. You should probably disable the qeupgradehelper cron settings now.');
break;
// No more to do;
}
$quizid = $quiz->id;
$quizsummary = tool_qeupgradehelper_get_quiz($quizid);
if ($quizsummary) {
mtrace(' starting upgrade of attempts at quiz ' . $quizid);
$upgrader = new tool_qeupgradehelper_attempt_upgrader($quizsummary->id, $quizsummary->numtoconvert);
$upgrader->convert_all_quiz_attempts();
mtrace(' upgrade of quiz ' . $quizid . ' complete.');
}
}
mtrace('qeupgradehelper: Done.');
return;
}
示例15: handlerRequest
public static function handlerRequest($data = NULL)
{
try {
// se é uma chamada Ajax, inicializa MAjax
if (Manager::isAjaxCall()) {
Manager::$ajax = new \Maestro\UI\MAjax(Manager::getOptions('charset'));
}
MApp::contextualize();
self::setData($data ?: $_REQUEST);
mtrace('DTO Data:');
mtrace(self::getData());
self::init();
do {
self::$result = MApp::handler();
} while (self::$forward != '');
self::terminate();
} catch (\Maestro\Services\Exception\ENotFoundException $e) {
self::$result = new Results\MNotFound($e);
} catch (\Maestro\Services\Exception\ESecurityException $e) {
self::$result = new Results\MInternalError($e);
} catch (\Maestro\Services\Exception\ETimeOutException $e) {
self::$result = new Results\MInternalError($e);
} catch (\Maestro\Services\Exception\ERuntimeException $e) {
self::$result = new Results\MRunTimeError($e);
} catch (\Maestro\Services\Exception\EMException $e) {
self::$result = new Results\MInternalError($e);
} catch (\Exception $e) {
self::$result = new Results\MInternalError($e);
}
}