本文整理汇总了PHP中Logs::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Logs::save方法的具体用法?PHP Logs::save怎么用?PHP Logs::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logs
的用法示例。
在下文中一共展示了Logs::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionView
public function actionView($id)
{
if (!empty($id)) {
$contenido = Contenido::model()->findByPk($id);
}
if (isset($_POST['Contenido'])) {
$contenido->texto = $_POST['Contenido']['texto'];
$log = new Logs();
try {
$log->accion = 'Edito el contenido de ' . $contenido->nombre . ' como admin';
$log->usuario = Yii::app()->user->id;
$log->msg = 'IP: ' . $_SERVER['REMOTE_ADDR'] . ' : ' . $_SERVER['REMOTE_PORT'];
$log->fecha = date('Y-m-d G:i:s');
$log->save();
} catch (Exception $e) {
$log->accion = 'Error log';
$log->msg = '';
$log->fecha = '';
$log->save();
}
$contenido->save('update');
}
// render - 1. vista 2. array con los objetos de tipo CActiveReord
$this->render('form', array('model' => $contenido));
}
示例2: logoutAction
public function logoutAction()
{
// Log out
if (Auth::User()) {
$user = new Usernhc();
$user_id = Auth::User()->id;
$user_info = $user->getUsernhcById($user_id);
$logs = new Logs();
$logs->ip = Request::getClientIp();
$logs->host = Request::root();
$logs->lastpage = '';
$logs->last_visit = date('Y-m-d H:i:s');
$logs->role_id = $user_info[0]->role_id;
$logs->data_id = rand(1, 11);
$logs->userid = $user_id;
$logs->save();
}
// Redirect to homepage
if (Auth::logout()) {
Auth::logout();
return Redirect::to('login')->with('success', 'ออกจากระบบสำเร็จ');
} else {
return Redirect::to('login')->with('success', 'ออกจากระบบสำเร็จ');
}
}
示例3: add
public static function add($action, $desc)
{
$log = new Logs();
$log->action = CHtml::encode($action);
$log->remarks = CHtml::encode($desc);
if ($log->save()) {
return TRUE;
}
return FALSE;
}
示例4: logs
private function logs($action, $tbName, $ID, $message)
{
$dates = $dates = date('Y-m-d H:i:s');
$modelss = new Logs();
$modelss->log_date = $dates;
$modelss->actions = $action;
$modelss->table_name = $tbName;
$modelss->curId = $ID;
$modelss->message = $message;
$modelss->save();
}
示例5: store
public function store()
{
$data = Input::all()['data'];
$bookID = $data['bookID'];
$studentID = $data['studentID'];
$student = Student::find($studentID);
if ($student == NULL) {
throw new Exception('Invalid Student ID');
} else {
$approved = $student->approved;
if ($approved == 0) {
throw new Exception('Student still not approved by Admin Librarian');
} else {
$books_issued = $student->books_issued;
$category = $student->category;
$max_allowed = StudentCategories::where('cat_id', '=', $category)->firstOrFail()->max_allowed;
if ($books_issued >= $max_allowed) {
throw new Exception('Student cannot issue any more books');
} else {
$book = Issue::find($bookID);
if ($book == NULL) {
throw new Exception('Invalid Book Issue ID');
} else {
$book_availability = $book->available_status;
if ($book_availability != 1) {
throw new Exception('Book not available for issue');
} else {
// book is to be issued
DB::transaction(function () use($bookID, $studentID) {
$log = new Logs();
$log->book_issue_id = $bookID;
$log->student_id = $studentID;
$log->issue_by = Auth::id();
$log->issued_at = time();
$log->return_time = 0;
$log->save();
// changing the availability status
$book = Issue::find($bookID);
$book->available_status = 0;
$book->save();
// increasing number of books issed by student
$student = Student::find($studentID);
$student->books_issued = $student->books_issued + 1;
$student->save();
});
return 'Successfully Issued';
}
}
}
}
}
}
示例6: authenticate
public function authenticate()
{
$correo = strtolower($this->correo);
$usuario = Usuario::model()->find('LOWER(correo)=?', array($correo));
if ($usuario === null) {
$this->errorCode = self::ERROR_USERNAME_INVALID;
} else {
if (!$usuario->validatePassword($this->password)) {
$this->errorCode = self::ERROR_PASSWORD_INVALID;
} else {
if ($usuario->estado == 0) {
$this->errorCode = self::ERROR_STATUS;
} else {
$this->_id = $usuario->id;
$this->correo = $usuario->correo;
$this->es_admin = $usuario->es_admin;
$this->errorCode = self::ERROR_NONE;
Yii::app()->user->setState('es_admin', $usuario->es_admin);
if ($usuario->es_admin == 1) {
Yii::app()->user->setState('user_type', 'Admin');
$log = new Logs();
try {
$log->accion = 'Ingreso al sistema como admin';
$log->usuario = 'usuario id' . $usuario->id . ' con ' . $usuario->correo;
$log->msg = 'IP: ' . $_SERVER['REMOTE_ADDR'] . ' : ' . $_SERVER['REMOTE_PORT'];
$log->fecha = date('Y-m-d G:i:s');
$log->save();
} catch (Exception $e) {
$log->accion = 'Error log';
$log->msg = '';
$log->fecha = '';
$log->save();
}
}
}
}
}
return $this->errorCode == self::ERROR_NONE;
}
示例7: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Logs();
$model->user_id = Yii::app()->user->id;
$model->page_id = $_REQUEST['page_id'];
$model->start = date('Y-m-d H:i:s');
$model->end = date('Y-m-d H:i:s');
$model->status = 123;
if ($model->save()) {
echo $model->id;
}
// else
// print_r($model->getErrors());
}
示例8: actionCreate
/**
* Creates a new model.
* @return create view
*/
public function actionCreate()
{
// create Logs object model
$model = new Logs();
// if Logs form exist
if (isset($_POST['Logs'])) {
// set form elements to Logs model attributes
$model->attributes = $_POST['Logs'];
// find module_name before save
$module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id)));
// set finded module_id to module->module_id
$model->module_id = $module->module_id;
// save without validate
$model->save(false);
}
}
示例9: postLogin
public function postLogin()
{
if (Request::ajax()) {
$username = Input::get('username');
$password = Input::get('password');
if (Input::has('remember')) {
$remember = Input::get('remember');
} else {
$remember = 0;
}
$data = array('username' => $username, 'password' => $password, 'active' => 1);
if (Auth::attempt($data, $remember)) {
$log = new Logs();
$log->user_id = Auth::user()->id;
$log->login = date('Y-m-d H:i:s', time());
$log->save();
return Response::json(array('type' => 'success', 'msg' => 'Ha iniciado sesión satisfactoriamente, espere a que se le redirija.'));
}
return Response::json(array('type' => 'danger', 'msg' => 'Usuario o contraseña incorrecta.'));
}
}
示例10: statvisits
function statvisits()
{
// log visiwebsite ==============================
$timestart = time();
$d = date('Y-m-d H:i:s');
$remote = getenv("REMOTE_ADDR");
$refer = @$_SERVER['HTTP_REFERER'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$cook_nm = 'G';
$strSQL = " SELECT logdate FROM sitelog Order by id desc LIMIT 0,1";
$objQuery = $this->db->query($strSQL);
$objResult = $objQuery->row_array();
$view_date = $objResult['logdate'];
if ($view_date != "") {
$hours = 0.1;
// 5 minute
if (date($view_date, time() + 3600 * $hours) > 4) {
$rs = new Logs();
$rs->logtime = $timestart;
$rs->logdate = $d;
$rs->ip = $remote;
$rs->refer = $refer;
$rs->browser = $browser;
$rs->username = $cook_nm;
$rs->save();
}
}
// save log visitwebsite ================================
$strSQL = " SELECT DATE FROM counter LIMIT 0,1";
$objQuery = $this->db->query($strSQL);
$objResult = $objQuery->row_array();
if ($objResult["DATE"] != date("Y-m-d")) {
$strSQL = " INSERT INTO daily (DATE,NUM) SELECT '" . date('Y-m-d', strtotime("-1 day")) . "',COUNT(*) AS intYesterday FROM counter WHERE 1 AND DATE = '" . date('Y-m-d', strtotime("-1 day")) . "'";
$this->db->query($strSQL);
$strSQL = " DELETE FROM counter WHERE DATE != '" . date("Y-m-d") . "' ";
$this->db->query($strSQL);
}
$strSQL = " INSERT INTO counter (DATE,IP) VALUES ('" . date("Y-m-d") . "','" . $_SERVER["REMOTE_ADDR"] . "') ";
$this->db->query($strSQL);
$strSQL = " SELECT COUNT(DATE) AS CounterToday FROM counter WHERE DATE = '" . date("Y-m-d") . "' ";
$objQuery = $this->db->query($strSQL);
$objResult = $objQuery->row_array();
$strToday = $objResult["CounterToday"];
$strSQL = " SELECT SUM(NUM) AS CountMonth FROM daily WHERE DATE_FORMAT(DATE,'%Y-%m') = '" . date('Y-m') . "' ";
$objQuery = $this->db->query($strSQL);
$objResult = $objQuery->row_array();
$strThisMonth = $objResult["CountMonth"];
$strSQL = " SELECT SUM(NUM) AS CountYear FROM daily WHERE DATE_FORMAT(DATE,'%Y') = '" . date('Y') . "' ";
$objQuery = $this->db->query($strSQL);
$objResult = $objQuery->row_array();
$strThisYear = $objResult["CountYear"];
$strSQL = " SELECT SUM(NUM) AS CountYear FROM daily WHERE DATE_FORMAT(DATE,'%Y') = '" . date('Y', strtotime("-1 year")) . "' ";
$objQuery = $this->db->query($strSQL);
$objResult = $objQuery->row_array();
$strLastYear = $objResult["CountYear"];
$strSQL = " SELECT * FROM daily ORDER BY DATE ASC";
$objQuery = $this->db->query($strSQL);
$objResult = $objQuery->row_array();
$strbeginDate = $objResult["DATE"];
$strSQL = " SELECT * FROM sitelog ORDER BY id ASC";
$objQuery = $this->db->query($strSQL);
$AllData = $objQuery->num_rows();
$data['beginip'] = $strbeginDate;
$data['todayip'] = $strToday;
$data['monthip'] = $strThisMonth;
$data['yearip'] = $strThisYear;
$data['allip'] = $AllData;
$this->load->view('home_footer', $data);
}
示例11: bothRoutes
<?php
Logs::save();
function bothRoutes($route, $var = null)
{
switch ($route) {
case 'post:posts':
return new PostsController('create');
case 'get:posts-num':
return new PostsController('read');
case 'put:posts-num':
return new PostsController('update');
case 'delete:posts-num':
return new PostsController('delete');
case 'get:posts':
return new PostsController('all');
case 'get:posts-slug-var':
return new PostsController('readBySlug', $var);
case 'get:posts-search-var':
return new PostsController('search', $var);
case 'get:gamers':
return new GamersController('all');
case 'post:users-facebook':
return new UsersController('singinByFacebook');
case 'post:users-token':
return new UsersController('readByToken');
case 'post:ms-newlesson':
return new MesalvaController('newLesson');
case 'post:ms-readlesson':
return new MesalvaController('readLesson');
default:
示例12: actionDelete
public function actionDelete($id)
{
$prx = new PreguntaXRonda();
$rxj = new RespuestaXJugador();
$res = new Respuesta();
$pre = new Pregunta();
$criteria = new CDbCriteria();
$criteria->join = 'inner join pregunta p ON respuesta_x_jugador.pregunta_id = p.id';
$criteria->condition = 'p.id=' . $id;
$prx->deleteAll("pregunta_id = {$id}");
$rxj->deleteAll($criteria);
$res->deleteAll("pregunta_id = {$id}");
$pre->deleteAll("id = {$id}");
$log = new Logs();
try {
$log->accion = 'Elimino la pregunta id #' . $id . ' como admin';
$log->usuario = Yii::app()->user->id;
$log->msg = 'IP: ' . $_SERVER['REMOTE_ADDR'] . ' : ' . $_SERVER['REMOTE_PORT'];
$log->fecha = date('Y-m-d G:i:s');
$log->save();
} catch (Exception $e) {
$log->accion = 'Error log';
$log->msg = '';
$log->fecha = '';
$log->save();
}
$this->redirect(array('index'));
}
示例13: actionRespuesta
public function actionRespuesta()
{
$this->layout = "single";
if (!Yii::app()->request->isAjaxRequest) {
throw new CHttpException('403', 'Forbidden access.');
}
$id = Yii::app()->request->restParams['id'];
// Validar token
if ($this->validarToken()) {
if ($this->validarCuentas()) {
$respuesta = Respuesta::model()->find('id = ?', array(0 => $id));
$pregunta = Pregunta::model()->find('id = ?', array(0 => $respuesta->pregunta->id));
$puntos = $respuesta->pregunta->nivel->puntos;
//$pregunta->estado = 0;
//$pregunta->save();
$respuestaJugador = new RespuestaXJugador();
$log = new Logs();
$respuestaJugador->pregunta_id = $respuesta->pregunta->id;
$respuestaJugador->respuesta_id = $id;
$respuestaJugador->jugador_id = Yii::app()->session['jugador_id'];
$respuestaJugador->fecha = date('Y-m-d G:i:s');
$respuestaJugador->ip = $_SERVER['REMOTE_ADDR'] . ' : ' . $_SERVER['REMOTE_PORT'];
try {
if (Yii::app()->user->id) {
$jugador = Jugador::model()->find('usuario_id = ' . Yii::app()->user->id);
if ($jugador != NULL) {
$log->usuario = 'id ' . $jugador->id . ' - ' . $jugador->nombre;
} else {
$log->usuario = 'id ' . $jugador->id;
}
}
$msg_res = $respuesta->es_correcta == 1 ? 'correcta' : 'incorrecta';
$log->accion = 'Contesto Pregunta # ' . $respuesta->pregunta->id;
$log->msg = 'IP: ' . $_SERVER['REMOTE_ADDR'] . ' : ' . $_SERVER['REMOTE_PORT'] . '- Contesto "' . $pregunta->pregunta . '"' . '- Su Respuesta fue # ' . $id . '- "' . $respuesta->respuesta . '"' . '- Con respuesta ' . $msg_res;
$log->fecha = date('Y-m-d G:i:s');
$log->save();
} catch (Exception $e) {
$log->accion = 'Error log';
$log->msg = '';
$log->fecha = date('Y-m-d G:i:s');
$log->save();
}
$respuestaJugador->save();
$respuesta = Respuesta::model()->find('id = ?', array(0 => $id));
$r = array();
switch ($respuesta->es_correcta == 1) {
case true:
// Respuesta correcta , que por ley no se puede informar al usuario.
$r['message'] = 'Gracias por participar, recuerda revisar tu perfil al final del día para saber los resultados.';
$r['status'] = 'success';
break;
case false:
// Respuesta Incorrecta , que por ley no se puede informar al usuario.
$r['message'] = 'Gracias por participar, recuerda revisar tu perfil al final del día para saber los resultados.';
/**
* formato viejo
**/
$r['status'] = 'success';
// $r['status'] = 'error';
break;
}
/**
*
* Formato Viejo , por seguridad ya no se m
* mandan los puntos al JS.
**/
//$r['puntos'] = $puntos;
$r['puntos'] = 'null';
$this->clearTokenVal();
} else {
$r = array();
$r['message'] = 'Moral error: No puedes jugar aun.';
$r['status'] = 'error';
// Codigo 3 debe estar en el contenido de la base de datos .
$this->redirect(array('site/contenido', 'id' => 3));
Yii::app()->end();
}
} else {
$r = array();
$r['message'] = 'Error , token de seguridad invalido.';
$r['status'] = 'error';
}
header('Content-Type: application/json; charset="UTF-8"');
echo CJSON::encode($r);
Yii::app()->end();
}
示例14: createLogout
/**
* 添加登出日志
* @param $userId
* @param $device_type
* @return Logs
*/
public function createLogout($userId, $device_type)
{
$logs = new Logs();
$logs['message'] = $this->getIP();
//当前登出用户的IP
$logs['user_id'] = $userId;
$logs['type'] = 0;
$arr = array("action" => MConst::LOGOUT, "device_type" => $device_type);
$logs['context'] = serialize($arr);
$logs->save();
return $logs;
}
示例15: saveLog
public function saveLog($modelAttributes, $sendMail = false)
{
$module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $modelAttributes['module_id'])));
$modelAttributes['module_id'] = $module->module_id;
$model = new Logs();
$model->attributes = $modelAttributes;
if ($model->save()) {
/*if ($sendMail)
$this->sendEmailAlert($modelAttributes);*/
}
}