本文整理汇总了PHP中add_log函数的典型用法代码示例。如果您正苦于以下问题:PHP add_log函数的具体用法?PHP add_log怎么用?PHP add_log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Insert
/** Update the content of the file */
function Insert()
{
if (!$this->BuildId || !is_numeric($this->BuildId)) {
add_log("BuildId not set", "CoverageFileLog::Insert()", LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_COVERAGE, $this->FileId);
return false;
}
if (!$this->FileId || !is_numeric($this->FileId)) {
add_log("FileId not set", "CoverageFileLog::Insert()", LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_COVERAGE, $this->FileId);
return false;
}
$log = '';
foreach ($this->Lines as $lineNumber => $code) {
$log .= $lineNumber . ':' . $code . ';';
}
foreach ($this->Branches as $lineNumber => $code) {
$log .= 'b' . $lineNumber . ':' . $code . ';';
}
if ($log != '') {
$sql = "INSERT INTO coveragefilelog (buildid,fileid,log) VALUES ";
$sql .= "(" . qnum($this->BuildId) . "," . qnum($this->FileId) . ",'" . $log . "')";
pdo_query($sql);
add_last_sql_error("CoverageFileLog::Insert()");
}
return true;
}
示例2: cdashmail
function cdashmail($to, $subject, $body, $headers = false)
{
if (empty($to)) {
add_log('Cannot send email. Recipient is not set.', 'cdashmail', LOG_ERR);
return false;
}
global $CDASH_USE_SENDGRID;
if ($CDASH_USE_SENDGRID) {
return _cdashsendgrid($to, $subject, $body);
}
$to = explode(', ', $to);
global $CDASH_EMAIL_FROM, $CDASH_EMAIL_REPLY;
$message = Swift_Message::newInstance()->setTo($to)->setSubject($subject)->setBody($body)->setFrom(array($CDASH_EMAIL_FROM => 'CDash'))->setReplyTo($CDASH_EMAIL_REPLY)->setContentType('text/plain')->setCharset('UTF-8');
global $CDASH_EMAIL_SMTP_HOST, $CDASH_EMAIL_SMTP_PORT, $CDASH_EMAIL_SMTP_ENCRYPTION, $CDASH_EMAIL_SMTP_LOGIN, $CDASH_EMAIL_SMTP_PASS;
if (is_null($CDASH_EMAIL_SMTP_HOST)) {
// Use the PHP mail() function.
$transport = Swift_MailTransport::newInstance();
} else {
// Use an SMTP server to send mail.
$transport = Swift_SmtpTransport::newInstance($CDASH_EMAIL_SMTP_HOST, $CDASH_EMAIL_SMTP_PORT, $CDASH_EMAIL_SMTP_ENCRYPTION);
if (!is_null($CDASH_EMAIL_SMTP_LOGIN) && !is_null($CDASH_EMAIL_SMTP_PASS)) {
$transport->setUsername($CDASH_EMAIL_SMTP_LOGIN)->setPassword($CDASH_EMAIL_SMTP_PASS);
}
}
$mailer = Swift_Mailer::newInstance($transport);
return $mailer->send($message) > 0;
}
示例3: handle_gb_post_delete
/**
* Do the various checks required for removing posts as well as removing it
*/
function handle_gb_post_delete($post_id, &$post_data, &$guestbook)
{
global $user, $db, $auth, $config;
global $phpbb_root_path, $phpEx;
// If moderator removing post or user itself removing post, present a confirmation screen
if ($auth->acl_get('m_gb_delete') || $post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('u_gb_delete') && ($post_data['post_time'] > time() - $config['delete_time'] * 60 || !$config['delete_time'])) {
$s_hidden_fields = build_hidden_fields(array('p' => $post_id, 'gbmode' => 'delete'));
if (confirm_box(true)) {
$data = array('post_time' => $post_data['post_time'], 'poster_id' => $post_data['poster_id']);
$next_post_id = gb_delete_post($post_id, $data, $guestbook);
$post_username = $post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username']) ? $post_data['post_username'] : $post_data['username'];
add_log('mod', 0, 0, 'LOG_GB_DELETE_POST', $post_username);
$member = $guestbook->getmember();
$meta_info = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $member['user_id']);
unset($member);
$message = $user->lang['POST_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_PROFILE'], '<a href="' . $meta_info . '">', '</a>');
meta_refresh(3, $meta_info);
trigger_error($message);
} else {
confirm_box(false, 'DELETE_POST', $s_hidden_fields);
}
redirect(append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . request_var('u', 0)));
}
// If we are here the user is not able to delete - present the correct error message
if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('u_gb_delete')) {
trigger_error('DELETE_OWN_POSTS');
}
trigger_error('USER_CANNOT_DELETE');
}
示例4: main
function main($id, $mode)
{
global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('acp/board');
$captcha_vars = array('captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS');
if (isset($_GET['demo'])) {
$captcha_vars = array_keys($captcha_vars);
foreach ($captcha_vars as $captcha_var) {
$config[$captcha_var] = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var];
}
if ($config['captcha_gd']) {
include $phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx;
} else {
include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx;
}
$captcha = new captcha();
$captcha->execute(gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)), time());
exit;
}
$config_vars = array('enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', 'confirm_refresh' => 'CONFIRM_REFRESH', 'captcha_gd' => 'CAPTCHA_GD');
$this->tpl_name = 'acp_captcha';
$this->page_title = 'ACP_VC_SETTINGS';
$form_key = 'acp_captcha';
add_form_key($form_key);
$submit = request_var('submit', '');
if ($submit && check_form_key($form_key)) {
$config_vars = array_keys($config_vars);
foreach ($config_vars as $config_var) {
set_config($config_var, request_var($config_var, ''));
}
$captcha_vars = array_keys($captcha_vars);
foreach ($captcha_vars as $captcha_var) {
$value = request_var($captcha_var, 0);
if ($value >= 0) {
set_config($captcha_var, $value);
}
}
add_log('admin', 'LOG_CONFIG_VISUAL');
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
} else {
if ($submit) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action));
} else {
$preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&demo=demo"));
if (@extension_loaded('gd')) {
$template->assign_var('GD', true);
}
foreach ($config_vars as $config_var => $template_var) {
$template->assign_var($template_var, isset($_REQUEST[$config_var]) ? request_var($config_var, '') : $config[$config_var]);
}
foreach ($captcha_vars as $captcha_var => $template_var) {
$var = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var];
$template->assign_var($template_var, $var);
$preview_image_src .= "&{$captcha_var}=" . $var;
}
$template->assign_vars(array('CAPTCHA_PREVIEW' => $preview_image_src, 'PREVIEW' => isset($_POST['preview'])));
}
}
}
示例5: acp_page
function acp_page($id, &$module)
{
global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$user->add_lang('acp/board');
$config_vars = array('enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', 'confirm_refresh' => 'CONFIRM_REFRESH', 'captcha_gd' => 'CAPTCHA_GD');
$module->tpl_name = 'captcha_gd_acp';
$module->page_title = 'ACP_VC_SETTINGS';
$form_key = 'acp_captcha';
add_form_key($form_key);
$submit = request_var('submit', '');
if ($submit && check_form_key($form_key)) {
$captcha_vars = array_keys($this->captcha_vars);
foreach ($captcha_vars as $captcha_var) {
$value = request_var($captcha_var, 0);
if ($value >= 0) {
set_config($captcha_var, $value);
}
}
add_log('admin', 'LOG_CONFIG_VISUAL');
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action));
} else {
if ($submit) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action));
} else {
foreach ($this->captcha_vars as $captcha_var => $template_var) {
$var = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var];
$template->assign_var($template_var, $var);
}
$template->assign_vars(array('CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), 'U_ACTION' => $module->u_action));
}
}
}
示例6: Insert
function Insert()
{
if (!$this->BuildId) {
add_log('BuildId is not set', 'BuildTest::Insert()', LOG_ERR, 0, 0);
return false;
}
if (!$this->TestId) {
add_log('TestId is not set', 'BuildTest::Insert()', LOG_ERR, 0, $this->BuildId);
return false;
}
if (empty($this->Time)) {
$this->Time = 0;
}
if (empty($this->TimeMean)) {
$this->TimeMean = 0;
}
if (empty($this->TimeStd)) {
$this->TimeStd = 0;
}
if (empty($this->TimeStatus)) {
$this->TimeStatus = 0;
}
$query = "INSERT INTO build2test (buildid,testid,status,time,timemean,timestd,timestatus)\n VALUES (" . qnum($this->BuildId) . "," . qnum($this->TestId) . ",'{$this->Status}'," . qnum($this->Time) . "," . qnum($this->TimeMean) . "," . qnum($this->TimeStd) . "," . qnum($this->TimeStatus) . ")";
if (!pdo_query($query)) {
add_last_sql_error("BuildTest:Insert", 0, $this->BuildId);
return false;
}
return true;
}
示例7: endElement
/** End Element */
public function endElement($parser, $name)
{
$parent = $this->getParent();
// should be before endElement
parent::endElement($parser, $name);
if ($name == "STARTDATETIME" && $parent == 'COVERAGELOG') {
$start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp);
$this->Build->ProjectId = $this->projectid;
$this->BuildId = $this->Build->GetIdFromName($this->SubProjectName);
if ($this->BuildId == 0) {
$t = 'Cannot add a coverage log to a build that does not exist';
$f = 'CoverageLogHandler::endElement';
add_log($t, $f, LOG_ERR, $this->projectid);
}
} else {
if ($name == 'LINE') {
$this->CoverageFile->File .= '<br>';
// cannot be <br/> for backward compatibility
} else {
if ($name == 'FILE') {
if ($this->BuildId != 0) {
$this->CoverageFile->Update($this->BuildId);
$this->CoverageFileLog->BuildId = $this->BuildId;
$this->CoverageFileLog->FileId = $this->CoverageFile->Id;
$this->CoverageFileLog->Insert();
}
unset($this->CoverageFile);
unset($this->CoverageFileLog);
}
}
}
}
示例8: ProcessFile
function ProcessFile($projectid, $filename, $md5)
{
unset($fp);
if (!file_exists($filename)) {
// check in parent dir also
$filename = "../{$filename}";
}
if (file_exists($filename)) {
$fp = fopen($filename, 'r');
}
if (@$fp) {
global $PHP_ERROR_SUBMISSION_ID;
do_submit($fp, $projectid, $md5, false, $PHP_ERROR_SUBMISSION_ID);
$PHP_ERROR_SUBMISSION_ID = 0;
@fclose($fp);
unset($fp);
global $CDASH_BACKUP_TIMEFRAME;
if ($CDASH_BACKUP_TIMEFRAME != '0') {
// Delete the temporary backup file since we now have a better-named one.
cdash_unlink($filename);
}
$new_status = 2;
// done, did call do_submit, finished normally
} else {
add_log("Cannot open file '" . $filename . "'", 'ProcessFile', LOG_ERR, $projectid);
$new_status = 3;
// done, did *NOT* call do_submit
}
return $new_status;
}
示例9: main
function main($id, $mode)
{
global $db, $user, $auth, $template, $cache;
global $config, $src_root_path, $src_admin_path, $phpEx;
include $src_root_path . 'includes/functions_user.' . $phpEx;
$user->add_lang('acp/posting');
// Set up general vars
$this->tpl_name = 'acp_disallow';
$this->page_title = 'ACP_DISALLOW_USERNAMES';
$form_key = 'acp_disallow';
add_form_key($form_key);
$disallow = isset($_POST['disallow']) ? true : false;
$allow = isset($_POST['allow']) ? true : false;
if (($allow || $disallow) && !check_form_key($form_key)) {
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if ($disallow) {
$disallowed_user = str_replace('*', '%', utf8_normalize_nfc(request_var('disallowed_user', '', true)));
if (!$disallowed_user) {
trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$sql = 'SELECT disallow_id
FROM ' . DISALLOW_TABLE . "\n\t\t\t\tWHERE disallow_username = '" . $db->sql_escape($disallowed_user) . "'";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row) {
trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user));
$db->sql_query($sql);
$cache->destroy('_disallowed_usernames');
$message = $user->lang['DISALLOW_SUCCESSFUL'];
add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user));
trigger_error($message . adm_back_link($this->u_action));
} else {
if ($allow) {
$disallowed_id = request_var('disallowed_id', 0);
if (!$disallowed_id) {
trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$sql = 'DELETE FROM ' . DISALLOW_TABLE . '
WHERE disallow_id = ' . $disallowed_id;
$db->sql_query($sql);
$cache->destroy('_disallowed_usernames');
add_log('admin', 'LOG_DISALLOW_DELETE');
trigger_error($user->lang['DISALLOWED_DELETED'] . adm_back_link($this->u_action));
}
}
// Grab the current list of disallowed usernames...
$sql = 'SELECT *
FROM ' . DISALLOW_TABLE;
$result = $db->sql_query($sql);
$disallow_select = '';
while ($row = $db->sql_fetchrow($result)) {
$disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
}
$db->sql_freeresult($result);
$template->assign_vars(array('U_ACTION' => $this->u_action, 'S_DISALLOWED_NAMES' => $disallow_select));
}
示例10: cdashmail
function cdashmail($to, $subject, $body, $headers)
{
if (!empty($to)) {
return mail("{$to}", "{$subject}", "{$body}", "{$headers}");
}
add_log("Cannot send email. Receipient is not set");
return false;
}
示例11: _after_insert
function _after_insert($data, $options)
{
$xid = $data["xid"];
$xmk = M("Xmk");
$xmk->where("id={$xid}")->setField("update_time", time());
$progress = $xmk->where("id={$xid}")->getField("progress");
add_log($xid, "进展", $progress);
}
示例12: Parse
/**
* Parse a tarball of JSON files.
**/
public function Parse($filename)
{
// Create a new directory where we can extract our tarball.
$dirName = sys_get_temp_dir() . '/' . pathinfo($filename, PATHINFO_FILENAME);
mkdir($dirName);
// Extract the tarball.
$result = extract_tar($filename, $dirName);
if ($result === false) {
add_log('Could not extract ' . $filename . ' into ' . $dirName, 'JSCoverTarHandler::Parse', LOG_ERR);
return false;
}
// Recursively search for .json files and parse them.
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST);
$coverageSummary = $this->CoverageSummaries['default'];
foreach ($iterator as $fileinfo) {
// need the longest extension, so getExtension() won't do here.
$ext = substr(strstr($fileinfo->getFilename(), '.'), 1);
if ($ext === 'json') {
$this->ParseJSCoverFile($fileinfo);
}
}
// Record parsed coverage info to the database.
foreach ($this->CoverageFileLogs as $path => $coverageFileLog) {
$coverage = $this->Coverages[$path];
$coverageFile = $this->CoverageFiles[$path];
// Tally up how many lines of code were covered & uncovered.
foreach ($coverageFileLog->Lines as $line) {
if ($line == 0) {
$coverage->LocUntested += 1;
} else {
$coverage->Covered = 1;
$coverage->LocTested += 1;
}
}
// Save these models to the database.
$coverageFile->TrimLastNewline();
$coverageFile->Update($this->Build->Id);
$coverageFileLog->BuildId = $this->Build->Id;
$coverageFileLog->FileId = $coverageFile->Id;
$coverageFileLog->Insert();
// Add this Coverage to our summary.
$coverage->CoverageFile = $coverageFile;
$coverageSummary->AddCoverage($coverage);
}
// Insert coverage summaries
$completedSummaries = array();
foreach ($this->CoverageSummaries as $coverageSummary) {
if (in_array($coverageSummary->BuildId, $completedSummaries)) {
continue;
}
$coverageSummary->Insert();
$coverageSummary->ComputeDifference();
$completedSummaries[] = $coverageSummary->BuildId;
}
// Delete the directory when we're done.
DeleteDirectory($dirName);
return true;
}
示例13: removeFirstBuilds
/** Remove the first builds that are at the beginning of the queue */
function removeFirstBuilds($projectid, $days, $maxbuilds, $force = false)
{
require 'config/config.php';
require_once 'include/pdo.php';
require_once 'include/common.php';
@set_time_limit(0);
if (!$force && !isset($CDASH_AUTOREMOVE_BUILDS)) {
return;
}
if (!$force && $CDASH_AUTOREMOVE_BUILDS != '1') {
return;
}
if ($days < 2) {
return;
}
// First remove the builds with the wrong date
$currentdate = time() - 3600 * 24 * $days;
$startdate = date(FMT_DATETIME, $currentdate);
add_log('about to query for builds to remove', 'removeFirstBuilds');
$builds = pdo_query("SELECT id FROM build\n WHERE parentid IN (0, -1) AND\n starttime<'{$startdate}' AND\n projectid=" . qnum($projectid) . "\n ORDER BY starttime ASC LIMIT {$maxbuilds}");
add_last_sql_error('dailyupdates::removeFirstBuilds');
$buildids = array();
while ($builds_array = pdo_fetch_array($builds)) {
$buildids[] = $builds_array['id'];
}
$s = 'removing old buildids for projectid: ' . $projectid;
add_log($s, 'removeFirstBuilds');
echo ' -- ' . $s . "\n";
// for "interactive" command line feedback
remove_build($buildids);
// Remove any job schedules that are older than our cutoff date
// and not due to repeat again.
require_once 'models/constants.php';
require_once 'models/clientjobschedule.php';
$sql = 'SELECT scheduleid FROM client_job AS cj
LEFT JOIN client_jobschedule AS cjs ON cj.scheduleid = cjs.id
WHERE cj.status > ' . CDASH_JOB_RUNNING . "\n AND cjs.projectid={$projectid} AND cj.startdate < '{$startdate}'\n AND (cjs.repeattime = 0.00 OR\n (cjs.enddate < '{$startdate}' AND cjs.enddate != '1980-01-01 00:00:00'))";
$job_schedules = pdo_query($sql);
while ($job_schedule = pdo_fetch_array($job_schedules)) {
$ClientJobSchedule = new ClientJobSchedule();
$ClientJobSchedule->Id = $job_schedule['scheduleid'];
$ClientJobSchedule->Remove();
}
// Remove any jobs that are older than our cutoff date.
// This occurs when a job schedule is set to continue repeating, but
// some of its past runs are older than our autoremove threshold.
require_once 'models/clientjob.php';
$sql = 'SELECT cj.id FROM client_job AS cj
LEFT JOIN client_jobschedule AS cjs ON cj.scheduleid = cjs.id
WHERE cj.status > ' . CDASH_JOB_RUNNING . "\n AND cjs.projectid={$projectid} AND cj.startdate < '{$startdate}'";
$jobs = pdo_query($sql);
while ($job = pdo_fetch_array($jobs)) {
$ClientJob = new ClientJob();
$ClientJob->Id = $job['id'];
$ClientJob->Remove();
}
}
示例14: run_tool
/**
* Run Tool
*
* Does the actual stuff we want the tool to do after submission
*/
function run_tool(&$error)
{
global $auth, $cache;
$cache->purge();
// Clear permissions
$auth->acl_clear_prefetch();
cache_moderators();
add_log('admin', 'LOG_PURGE_CACHE');
trigger_error('PURGE_CACHE_COMPLETE');
}
示例15: GetVersion
/** Get version */
function GetVersion()
{
if (!$this->Id) {
add_log("ClientOS::GetVersion()", "Id not set");
return;
}
$name = pdo_query("SELECT version FROM client_os WHERE id=" . qnum($this->Id));
$row = pdo_fetch_array($name);
return $row[0];
}