本文整理汇总了PHP中Log::addEntry方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::addEntry方法的具体用法?PHP Log::addEntry怎么用?PHP Log::addEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Log
的用法示例。
在下文中一共展示了Log::addEntry方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
public function check($content, $type, $additionalArgs = array())
{
if ($this->controller) {
$args['ip_address'] = Loader::helper('validation/ip')->getRequestIP();
$args['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
$args['content'] = $content;
foreach ($additionalArgs as $key => $value) {
$args[$key] = $value;
}
if (isset($args['user']) && is_object($args['user'])) {
$u = $args['user'];
} else {
$u = new User();
}
if (!isset($args['email']) && $u->isRegistered()) {
$ui = UserInfo::getByID($u->getUserID());
$args['email'] = $ui->getUserEmail();
}
$r = $this->controller->check($args);
if ($r) {
return true;
} else {
$c = Page::getCurrentPage();
if (is_object($c)) {
$logText .= t('URL: %s', Loader::helper('navigation')->getLinkToCollection($c, true));
$logText .= "\n";
}
if ($u->isRegistered()) {
$logText .= t('User: %s (ID %s)', $u->getUserName(), $u->getUserID());
$logText .= "\n";
}
$logText .= t('Type: %s', Loader::helper('text')->unhandle($type));
$logText .= "\n";
foreach ($args as $key => $value) {
$logText .= Loader::helper('text')->unhandle($key) . ': ' . $value . "\n";
}
if (Config::get('ANTISPAM_LOG_SPAM')) {
Log::addEntry($logText, t('spam'));
}
if (Config::get('ANTISPAM_NOTIFY_EMAIL') != '') {
$mh = Loader::helper('mail');
$mh->to(Config::get('ANTISPAM_NOTIFY_EMAIL'));
$mh->addParameter('content', $logText);
$mh->load('spam_detected');
$mh->sendMail();
}
return false;
}
} else {
return true;
// return true if it passes the test
}
}
示例2: notifyAdmin
protected function notifyAdmin($offenderID)
{
$offender = UserInfo::getByID($offenderID);
$ue = new \Concrete\Core\User\Event\UserInfo($offender);
Events::dispatch('on_private_message_over_limit', $ue);
$admin = UserInfo::getByID(USER_SUPER_ID);
Log::addEntry(t("User: %s has tried to send more than %s private messages within %s minutes", $offender->getUserName(), Config::get('concrete.user.private_messages.throttle_max'), Config::get('concrete.user.private_messages.throttle_max_timespan')), t('warning'));
$mh = Loader::helper('mail');
$mh->addParameter('offenderUname', $offender->getUserName());
$mh->addParameter('profileURL', View::url('/profile', 'view', $offender->getUserID()));
$mh->addParameter('profilePreferencesURL', View::url('/profile/edit'));
$mh->to($admin->getUserEmail());
$mh->addParameter('siteName', tc('SiteName', Config::get('concrete.site')));
$mh->load('private_message_admin_warning');
$mh->sendMail();
}
示例3: moveToTrash
public function moveToTrash()
{
$trash = Page::getByPath(TRASH_PAGE_PATH);
Log::addEntry(t('Page "%s" at path "%s" Moved to trash', $this->getCollectionName(), $this->getCollectionPath()), t('Page Action'));
$this->move($trash);
$this->deactivate();
$pages = array();
$pages = $this->populateRecursivePages($pages, array('cID' => $this->getCollectionID()), $this->getCollectionParentID(), 0, false);
$db = Loader::db();
foreach ($pages as $page) {
$db->Execute('update Pages set cIsActive = 0 where cID = ?', array($page['cID']));
}
}
示例4: notifyAdmin
protected function notifyAdmin($offenderID) {
$offender = UserInfo::getByID($offenderID);
Events::fire('on_private_message_over_limit', $offender);
$admin = UserInfo::getByID(USER_SUPER_ID);
Log::addEntry(t("User: %s has tried to send more than %s private messages within %s minutes", $offender->getUserName(), USER_PRIVATE_MESSAGE_MAX, USER_PRIVATE_MESSAGE_MAX_TIME_SPAN),t('warning'));
Loader::helper('mail');
$mh = new MailHelper();
$mh->addParameter('offenderUname', $offender->getUserName());
$mh->addParameter('profileURL', BASE_URL . View::url('/profile', 'view', $offender->getUserID()));
$mh->addParameter('profilePreferencesURL', BASE_URL . View::url('/profile/edit'));
$mh->to($admin->getUserEmail());
$mh->load('private_message_admin_warning');
$mh->sendMail();
}
示例5: addEntry
public function addEntry($user, ActionDescription $descr, $points = false, $date = null)
{
if (!$this->isUserPointActionActive()) {
return false;
}
if (is_object($user)) {
$user = UserInfo::getByID($user->getUserID());
$uID = $user->getUserID();
} else {
$uID = $user;
}
if (!isset($uID) || $uID <= 0) {
return false;
}
$g = $this->getUserPointActionBadgeGroupObject();
if ($g instanceof Group) {
if ($user instanceof UserInfo) {
$user = User::getByUserID($user->getUserID());
}
$user->enterGroup($g);
}
if ($date == null) {
$date = date('Y-m-d H:i:s');
}
if ($points === false) {
$points = $this->getUserPointActionDefaultPoints();
}
try {
$upe = new UserPointEntry();
$upe->upuID = $uID;
$upe->upaID = $this->upaID;
$upe->upPoints = $points;
$upe->timestamp = $date;
$descr = serialize($descr);
$upe->object = $descr;
$upe->save();
return $upe;
} catch (Exception $e) {
Log::addEntry(t("Error saving user point record: %s", $e->getMessage()), 'exceptions');
return false;
}
return true;
}
示例6: define
//causes dispatcher to skip the page rendering
define('C5_ENVIRONMENT_ONLY', true);
//prevents dispatcher from causing redirection to the base_url
define('REDIRECT_TO_BASE_URL', false);
//let's enable timezones
define('ENABLE_USER_TIMEZONES', true);
//since we can't define/redefine this for individual tests, we set to a value that's most likely to cause errors (vs '')
define('DIR_REL', '/blog');
// Force tests to start in en_US
define('SITE_LOCALE', 'en_US');
define('ACTIVE_LOCALE', 'en_US');
//this is where the magic happens
require DIR_BASE . '/concrete/dispatcher.php';
//add a user with Europe/Rome timezone
$uTest = UserInfo::getByUserName('testuser_it');
if (!is_object($uTest)) {
$uTest = UserInfo::add(array('uName' => 'testuser_it', 'uEmail' => 'testuser_it@concrete5.org', 'uPassword' => 'testpassword'));
}
$uTest->update(array('uTimezone' => 'Europe/Rome'));
define('TESTUSER_IT_ID', $uTest->getUserID());
$uTest = UserInfo::getByUserName('testuser_jp');
if (!is_object($uTest)) {
$uTest = UserInfo::add(array('uName' => 'testuser_jp', 'uEmail' => 'testuser_jp@concrete5.org', 'uPassword' => 'testpassword'));
}
$uTest->update(array('uTimezone' => 'Asia/Tokyo'));
define('TESTUSER_JP_ID', $uTest->getUserID());
// login the admin
User::getByUserID(USER_SUPER_ID, true);
Log::addEntry('bootsrapped', 'unit tests');
// include adodb-lib to avoid a PHPUnit problem with globals
include ADODB_DIR . '/adodb-lib.inc.php';
示例7: testLegacyLogSupport
public function testLegacyLogSupport()
{
Log::addEntry("this is my log entry.");
$le = LogEntry::getByID(1);
$this->assertEquals($le->getLevel(), Logger::DEBUG);
$this->assertEquals($le->getLevelName(), 'DEBUG');
$this->assertEquals($le->getMessage(), 'this is my log entry.');
/*
* old format here:
$l = new Log(LOG_TYPE_EMAILS, true, true);
$l->write('This is line one.');
$l->write('This is line two');
$l->close();
*/
$l = new GroupLogger(LOG_TYPE_EMAILS, Logger::DEBUG);
$l->write('This is line one.');
$l->write('This is line two.');
$l2 = new GroupLogger('test', Logger::CRITICAL);
$l2->write('OMG!');
$l2->close();
$l->close();
$le2 = LogEntry::getByID(2);
$le3 = LogEntry::getByID(3);
$this->assertEquals($le2->getLevel(), Logger::CRITICAL);
$this->assertEquals($le3->getLevel(), Logger::DEBUG);
$this->assertEquals($le3->getMessage(), "This is line one.\nThis is line two.");
$this->assertEquals($le2->getMessage(), "OMG!");
}
示例8: update
/**
* update
* Saves a version of the walk collection, but doesn't approve version
*
* @param string $json String-encoded JSON of walk
*/
public function update($json)
{
header('Content-Type: application/json');
try {
$cvID = $this->setJson($json);
// Set the eventbrite
$mw = new MirrorWalk($this->walk);
$mw->mirrorStart();
echo json_encode(['cID' => $this->walk->getPage()->getCollectionID(), 'cvID' => $cvID]);
$mw->mirrorEnd();
} catch (Exception $e) {
Log::addEntry('Walk error on walk ' . __FUNCTION__ . ': ', $e->getMessage());
echo json_encode(['cID' => $this->walk->getPage()->getCollectionID(), 'error' => true, 'action' => __FUNCTION__, 'msg' => (string) $e->getMessage()]);
http_response_code(500);
}
exit;
}
示例9: check
public function check($content, $type, $additionalArgs = array(), $user = false)
{
if ($this->controller) {
if (!$user) {
$user = new User();
}
$wlg = $this->getWhitelistGroup();
if ($wlg instanceof Group && $user->inGroup($wlg)) {
// Never spam if user is in the whitelist
return true;
}
/** @var \Concrete\Core\Permission\IPService $iph */
$iph = Core::make('helper/validation/ip');
$ip = $iph->getRequestIP();
$args['ip_address'] = $ip === false ? '' : $ip->getIp($ip::FORMAT_IP_STRING);
$args['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
$args['content'] = $content;
foreach ($additionalArgs as $key => $value) {
$args[$key] = $value;
}
if (isset($args['user']) && is_object($args['user'])) {
$u = $args['user'];
} else {
$u = new User();
}
if (!isset($args['email']) && $u->isRegistered()) {
$ui = UserInfo::getByID($u->getUserID());
$args['email'] = $ui->getUserEmail();
}
$r = $this->controller->check($args);
if ($r) {
return true;
} else {
$logText = '';
$c = Page::getCurrentPage();
if (is_object($c)) {
$logText .= t('URL: %s', Loader::helper('navigation')->getLinkToCollection($c, true));
$logText .= "\n";
}
if ($u->isRegistered()) {
$logText .= t('User: %s (ID %s)', $u->getUserName(), $u->getUserID());
$logText .= "\n";
}
$logText .= t('Type: %s', Loader::helper('text')->unhandle($type));
$logText .= "\n";
foreach ($args as $key => $value) {
$logText .= Loader::helper('text')->unhandle($key) . ': ' . $value . "\n";
}
if (Config::get('concrete.log.spam')) {
Log::addEntry($logText, t('spam'));
}
if (Config::get('concrete.spam.notify_email') != '') {
$mh = Loader::helper('mail');
$mh->to(Config::get('concrete.spam.notify_email'));
$mh->addParameter('content', $logText);
$mh->load('spam_detected');
$mh->sendMail();
}
return false;
}
} else {
return true;
// return true if it passes the test
}
}
示例10: package
/**
* @access private
*/
public function package($pkgHandle)
{
// loads and instantiates the object
$env = Environment::get();
$path = $env->getPath(FILENAME_PACKAGE_CONTROLLER, $pkgHandle);
if (file_exists($path)) {
require_once $path;
$isValidPkgHandle = true;
} else {
$msg = t('Warning - failed to load package with pkgHandle \'%1$s\'. Could not find package controller file: \'%2$s\'', $pkgHandle, $path);
Log::addEntry($msg, 'packages');
}
$class = Object::camelcase($pkgHandle) . "Package";
if (class_exists($class)) {
$cl = new $class();
return $cl;
} else {
// $class might not exist due to an invalid $pkgHandle (thus a wrong
// $class value), in which case a more relevant message will already be logged.
if ($isValidPkgHandle) {
$msg = t('Warning - failed to load package in directory \'%1$s\'. The package controller does not define the expected class: \'%2$s\'', $pkgHandle, $class);
Log::addEntry($msg, 'packages');
}
}
}