本文整理汇总了PHP中log类的典型用法代码示例。如果您正苦于以下问题:PHP log类的具体用法?PHP log怎么用?PHP log使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了log类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _send_reset
private function _send_reset($form)
{
$user_name = $form->reset->inputs["name"]->value;
$user = user::lookup_by_name($user_name);
if ($user && !empty($user->email)) {
$user->hash = random::hash();
$user->save();
$message = new View("reset_password.html");
$message->confirm_url = url::abs_site("password/do_reset?key={$user->hash}");
$message->user = $user;
Sendmail::factory()->to($user->email)->subject(t("Password Reset Request"))->header("Mime-Version", "1.0")->header("Content-type", "text/html; charset=UTF-8")->message($message->render())->send();
log::success("user", t("Password reset email sent for user %name", array("name" => $user->name)));
} else {
if (!$user) {
// Don't include the username here until you're sure that it's XSS safe
log::warning("user", t("Password reset email requested for user %user_name, which does not exist.", array("user_name" => $user_name)));
} else {
log::warning("user", t("Password reset failed for %user_name (has no email address on record).", array("user_name" => $user->name)));
}
}
// Always pretend that an email has been sent to avoid leaking
// information on what user names are actually real.
message::success(t("Password reset email sent"));
json::reply(array("result" => "success"));
}
示例2: cron
/**
* Берет список записей и генерирует документы
*/
public function cron()
{
$queue = $this->getList();
require_once ABS_PATH . '/classes/log.php';
$log = new log('docgen_cron/' . SERVER . '-%d%m%Y.log', 'a', "%d.%m.%Y %H:%M:%S: ");
foreach ($queue as $item) {
try {
$docGenClass = $this->getClass($item['class_name'], $item['class_params']);
$docGenClass->setData(mb_unserialize($item['fields']));
$docGenClass->setDocName($item['type'], $item['original_name']);
$docGenClass->beforeGenerate();
if ($docGenClass->isExcel($item['type'])) {
$ok = $docGenClass->generateExcel($item['type']);
} else {
$ok = $docGenClass->generate($item['type']);
}
if ($ok) {
$this->removeItem($item['id']);
} else {
$this->incrementTry($item['id']);
}
} catch (Exception $e) {
$log->writeln(sprintf("id = %s: %s", $item['id'], iconv('CP1251', 'UTF-8', $e->getMessage())));
$this->incrementTry($item['id']);
}
}
}
示例3: postNextTopStory
function postNextTopStory()
{
// only post one story every three hours
$tstamp = $this->statusObj->getState('lastTwitterPost');
if (!isset($_GET['test']) and time() - $tstamp < 60 * TWITTER_INTERVAL_MINUTES) {
return;
}
//echo 'continuing';
require_once PATH_CORE . '/classes/content.class.php';
$cObj = new content($this->db);
require_once PATH_CORE . '/classes/log.class.php';
$logObj = new log($this->db);
$topStories = $cObj->fetchUpcomingStories();
$uid = 1;
while ($data = $this->db->readQ($topStories)) {
if (!$this->checkLog($uid, $data->siteContentId) and $data->score >= TWITTER_SCORE_THRESHOLD) {
// post to twitter
$result = $this->update($data->siteContentId, $data->title);
if ($result) {
$logItem = $logObj->serialize(0, $uid, 'postTwitter', $data->siteContentId);
$logObj->add($logItem);
$this->statusObj->setState('lastTwitterPost', time());
}
// only do one at a time
return;
}
}
}
示例4: actionLog
public function actionLog()
{
$view = new ViewConstuctor();
$log = new \log();
$view->log = $log->getMessage();
$view->Display('Admin/Log');
}
示例5: saveLog
public function saveLog($xml)
{
// !!!
// @todo Вот не знаю стоит ли тут делать так, или все же легче вызвать self::initReqXml(); но там у нас сессия инициализируется
$this->_clientXml = new DOMDocument();
libxml_use_internal_errors(true);
if (!$this->_clientXml->loadXML($xml)) {
$this->_debug = 1;
$xe_levels = array(LIBXML_ERR_WARNING => 'WARNING', LIBXML_ERR_ERROR => 'ERROR', LIBXML_ERR_FATAL => 'FATAL');
foreach (libxml_get_errors() as $xe) {
$err .= $xe_levels[$xe->level] . ": (line: {$xe->line}, column: {$xe->column}): {$xe->message}";
}
libxml_clear_errors();
$this->error(EXTERNAL_ERR_WRONG_REQ, $err);
}
$ns_name = basename($this->_clientXml->documentElement->getAttribute('xmlns:f'));
if ($ns_name == '') {
$ns_name = basename($this->_clientXml->documentElement->getAttribute('xmlns:hh'));
} else {
$ns_name = 'freetray';
}
if ($ns_name == '') {
$ns_name = 'other';
}
$log = new log("external/{$ns_name}-%d%m%Y.log");
$log->writeln('--------------' . getRemoteIP() . '--------------');
$log->writeln($xml);
}
示例6: update
/**
* 通过id获取信息
*/
public function update($_POST)
{
$log = new log();
$log->addLog("update test", 1);
$columns[0] = "field1";
$values[0] = $_POST['field1'];
$columns[1] = "field2";
$values[1] = $_POST['field2'];
$row = $this->db->updateParamById("test", $columns, $values, "id", $_POST['id']);
return $row;
}
示例7: GetOne
public function GetOne($id)
{
$query = 'SELECT * FROM ' . $this->tableName . ' WHERE id=:id';
$param[':id'] = $id;
$res = $this->query($query, $param);
if (empty($res)) {
$log = new log();
$log->write('Trying to get unexisting article');
throw new E404Exception('The article with id=' . $id . ' was not found');
}
return $this->query($query, $param)[0];
}
示例8: payment
public function payment($sum)
{
// На бете альфе включаем дебаг режим
if (!is_release()) {
//$sum = 0.1;// @debug
$this->api->setDebug(true);
}
$result = $this->api->requestPayment(round((double) $sum, 2), $this->account->id);
if ($result['status'] == API_Webmoney::STATUS_SUCCESS) {
$process = $this->api->processPayment($this->api->merchant_transaction_id, $result['processor_transaction_id']);
switch ($process['status']) {
case API_Webmoney::STATUS_PAYMENT_PROGRESS:
case API_Webmoney::STATUS_PAYMENT_SUCCESS:
// Зачисляем деньги на бете/альфе
// if(!is_release()) {
// $paymentDateTime = date('d.m.Y H:i');
// $orderNumber = rand(1, 99999999);
// $descr = "WebMoney с кошелька {$this->data['wallet']} сумма - {$sum}, обработан {$paymentDateTime}, номер покупки - $orderNumber";
//
// $this->account->deposit($op_id, $this->account->id, $sum, $descr, 3, $sum, 12);
// }
return true;
break;
case API_Webmoney::STATUS_PAYMENT_FAIL:
ob_start();
var_dump($result);
var_dump($process);
$content = ob_get_clean();
$this->log->writeln("FAIL Payment:\naccount:{$this->account->id}\n");
$this->log->write("Request:\n " . $this->api->last_request->getBody());
$this->log->write("Result:\n {$content}");
return false;
break;
// Отложить платеж на пол часа
// @todo придумать как отложить запрос на потом
//case API_Webmoney::STATUS_PAYMENT_PROCESS:
// Отложить платеж на пол часа
// @todo придумать как отложить запрос на потом
//case API_Webmoney::STATUS_PAYMENT_PROCESS:
default:
return;
break;
}
} else {
ob_start();
var_dump($result);
$content = ob_get_clean();
$this->log->writeln("FAIL Payment:\naccount:{$this->account->id}\n");
$this->log->write("Request:\n " . $this->api->last_request->getBody());
$this->log->write("Result:\n {$content}");
return false;
}
}
示例9: registerPartido
/**
* Esta funcion guarda en el log para el sistema de auditoria
* @access public
* @author: fzalazar
* @param $accion: id de la accion
* @param $parametro: descripcion de la accion (opcional)
* @param $torneo: id del torneo (opcional)
* @param $rueda: rueda (opcional)
* @param $fecha: numero de fecha (opcional)
* @param $partido: partido (opcional)
* @return true si pudo insertar en el log, false en caso contrario
* @modificacion: dabiricha (agregado de parametros opcionales: torneo, rueda, fecha y partido)
*/
function registerPartido($accion, $parametro = '', $torneo = 0, $rueda = 0, $fecha = 0, $partido = 0)
{
$log = new log();
$log->id_accion = $accion;
$log->fecha = date("Y/m/d");
$log->hora = date("H:i:s");
$log->parametro = $parametro ? $parametro : NULL;
$log->torneo = $torneo;
$log->rueda = $rueda;
$log->numero_fecha = $fecha;
$log->partido = $partido;
$log->id_usuario = RegistryHelper::getIdUsuario();
return $log->insert();
}
示例10: start
static function start()
{
self::boot();
// 函数库
require CORE_PATH . 'load.php';
load::register();
// 自动加载,没有找到本地类的
register_shutdown_function('\\poem\\app::appFatal');
// 错误和异常处理
set_error_handler('\\poem\\app::appError');
set_exception_handler('\\poem\\app::appException');
t('POEM_TIME');
$module = defined('NEW_MODULE') ? NEW_MODULE : 'home';
if (!is_dir(APP_PATH . $module)) {
\poem\more\Build::checkModule($module);
}
Route::run();
// 路由管理
self::exec();
// 执行操作
t('POEM_TIME', 0);
if (!config('debug_trace') || IS_AJAX || IS_CLI) {
exit;
}
log::show();
exit;
}
示例11: _save_api_key
private function _save_api_key($form)
{
$new_key = $form->sharing->api_key->value;
if ($new_key && !l10n_client::validate_api_key($new_key)) {
$form->sharing->api_key->add_error("invalid", 1);
$valid = false;
} else {
$valid = true;
}
if ($valid) {
$old_key = l10n_client::api_key();
l10n_client::api_key($new_key);
if ($old_key && !$new_key) {
message::success(t("Your API key has been cleared."));
} else {
if ($old_key && $new_key && $old_key != $new_key) {
message::success(t("Your API key has been changed."));
} else {
if (!$old_key && $new_key) {
message::success(t("Your API key has been saved."));
}
}
}
log::success(t("gallery"), t("l10n_client API key changed."));
url::redirect("admin/languages");
} else {
// Show the page with form errors
$this->index($form);
}
}
示例12: _update
/**
* @see REST_Controller::_update($resource)
*/
public function _update($photo)
{
access::verify_csrf();
access::required("view", $photo);
access::required("edit", $photo);
$form = photo::get_edit_form($photo);
if ($valid = $form->validate()) {
if ($form->edit_photo->filename->value != $photo->name) {
// Make sure that there's not a conflict
if (Database::instance()->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->where("name", $form->edit_photo->filename->value)->count_records()) {
$form->edit_photo->filename->add_error("conflict", 1);
$valid = false;
}
}
}
if ($valid) {
$photo->title = $form->edit_photo->title->value;
$photo->description = $form->edit_photo->description->value;
$photo->rename($form->edit_photo->filename->value);
$photo->save();
module::event("photo_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"photos/{$photo->id}\">view</a>");
message::success(t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title))));
print json_encode(array("result" => "success", "location" => url::site("photos/{$photo->id}")));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
示例13: auth
public function auth()
{
if (!identity::active_user()->admin) {
access::forbidden();
}
access::verify_csrf();
$form = self::_form();
$valid = $form->validate();
$user = identity::active_user();
if ($valid) {
module::event("user_auth", $user);
if (!request::is_ajax()) {
message::success(t("Successfully re-authenticated!"));
}
url::redirect(Session::instance()->get_once("continue_url"));
} else {
$name = $user->name;
log::warning("user", t("Failed re-authentication for %name", array("name" => $name)));
module::event("user_auth_failed", $name);
if (request::is_ajax()) {
$v = new View("reauthenticate.html");
$v->form = $form;
$v->user_name = identity::active_user()->name;
json::reply(array("html" => (string) $v));
} else {
self::_show_form($form);
}
}
}
示例14: _update
/**
* @see REST_Controller::_update($resource)
*/
public function _update($photo)
{
access::verify_csrf();
access::required("view", $photo);
access::required("edit", $photo);
$form = photo::get_edit_form($photo);
$valid = $form->validate();
if ($valid = $form->validate()) {
if ($form->edit_item->filename->value != $photo->name || $form->edit_item->slug->value != $photo->slug) {
// Make sure that there's not a name or slug conflict
if ($row = Database::instance()->select(array("name", "slug"))->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->open_paren()->where("name", $form->edit_item->filename->value)->orwhere("slug", $form->edit_item->slug->value)->close_paren()->get()->current()) {
if ($row->name == $form->edit_item->filename->value) {
$form->edit_item->filename->add_error("name_conflict", 1);
}
if ($row->slug == $form->edit_item->slug->value) {
$form->edit_item->slug->add_error("slug_conflict", 1);
}
$valid = false;
}
}
}
if ($valid) {
$photo->title = $form->edit_item->title->value;
$photo->description = $form->edit_item->description->value;
$photo->slug = $form->edit_item->slug->value;
$photo->rename($form->edit_item->filename->value);
$photo->save();
module::event("item_edit_form_completed", $photo, $form);
log::success("content", "Updated photo", "<a href=\"{$photo->url()}\">view</a>");
message::success(t("Saved photo %photo_title", array("photo_title" => html::purify($photo->title))));
print json_encode(array("result" => "success"));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
示例15: test
public function test()
{
$username = "howdy";
$password = "123456";
$email = "gg@gmail.com";
$username2 = "bla2";
$password2 = "pass2";
$email2 = "gr@gmmail.com";
$username3 = "gue";
$password3 = "pass3";
$email3 = "eee@gmail.com";
user::create_new_user($username, $password, $email);
$this->assertEquals(1, user::getNumberOfUsers(), "number of users is not correct after adding a new user");
user::create_new_user($username2, $password2, $email2);
$this->assertEquals(2, user::getNumberOfUsers(), "number of users is not correct after adding a new user");
user::create_new_user($username3, $password3, $email3);
$this->assertEquals(3, user::getNumberOfUsers(), "number of users is not correct after adding a new user");
$user1ID = user::getUserByUsername($username)['id'];
$user2ID = user::getUserByUsername($username2)['id'];
$user3ID = user::getUserByUsername($username3)['id'];
$uuid1 = "352584060201362";
$this->assertTrue(safe_input::is_valid_uuid($uuid1), "safe_input::is_valid_uuid()");
$ip1 = '196.168.2.16';
$this->assertTrue(safe_input::is_valid_ip($ip1), "safe_input::is_valid_ip()");
$this->assertEquals(0, log::get_logs_count(), "[get_logs_count()]");
$this->assertTrue(log::addNewLog($user1ID, $ip1, $uuid1), "[log::addNewLog()]");
$this->assertEquals(1, log::get_logs_count(), "[get_logs_count()]");
$this->assertTrue(log::addNewLog($user1ID, $ip1, $uuid1), "[log::addNewLog()]");
$this->assertEquals(2, log::get_logs_count(), "[get_logs_count()]");
//$this->assertTrue(log::deleteSimilarLogs(),"[deleteSimilarLogs()]") ;
//$this->assertEquals(1,log::get_logs_count(),"[get_logs_count()]") ;
}