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)); }
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', 'ออกจากระบบสำเร็จ'); } }
function eventAction() { $t = new Logs(); $this->view->event = $event = $t->findOne($this->_getParam('id')); $this->metas(array('DC.Title' => 'Évènement')); $this->branche->append("Journal système", array('action' => 'log', 'id' => null)); $this->branche->append(); }
function log($level, $message, $url = null, $detail = null) { $user = Zend_Registry::get('user'); if (!$url) { $url = $_SERVER['REQUEST_URI']; } $data = array('logger' => $this->name, 'level' => $level, 'user' => $user->id, 'message' => $message, 'url' => $url, 'detail' => substr(serialize($detail), 0, 4096)); $t = new Logs(); return $t->insert($data); }
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; }
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(); }
function guarda_Cache(Cache $cacheArquivo, Contatos $contatos, Logs $logs) { $resultado["contatos"] = $contatos->buscaContatos($_SESSION["usuarioID"]); while ($data = mysqli_fetch_assoc($resultado["contatos"])) { $dados["contatos"][] = $data; } $resultado["logs"] = $logs->buscaLog($_SESSION["usuarioID"]); while ($data = mysqli_fetch_assoc($resultado["logs"])) { $dados["logs"][] = $data; } $valor = json_encode($dados); $cacheArquivo->set_valor($_SESSION["usuarioID"], $valor); }
public function logsReport($type, $startdt, $enddt) { $per_page = Config::get('nhc/site.ole_perpage'); $logs = new Logs(); $rs = $logs->getReportExport($type, $startdt, $enddt); $this->result_log_report = $rs; // return View::make('report.search')->with('paginator',$this->result_log_report); // var_dump($this->result_log_report); Excel::create('New file', function ($excel) { $excel->sheet('New sheet', function ($sheet) { $sheet->loadView('report.search_export')->with('paginator', $this->result_log_report); }); })->download('csv'); }
/** * 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); } }
private function _getFormatParams($params) { $ret = array(); foreach ($params as $param) { // Si llegamos a un params que es un array es cosa del constructor de Object, paramos if (is_array($param)) { break; } if (preg_match("/^--(.+)\$/", $param, $match)) { $ret[$match[1]] = true; } else { // Comprobamos que lo primero que llega no es un valor if (count($ret) == 0) { Logs::stFatal("mal muy mal"); } // Si es el primer valor lo guardamos normal if (is_bool($ret[end(array_keys($ret))])) { $ret[end(array_keys($ret))] = $param; } else { if (is_array($ret[end(array_keys($ret))])) { // Si ya es un array juntamos $ret[end(array_keys($ret))] = array_merge($ret[end(array_keys($ret))], array($param)); } else { // Si hay mas de uno lo guardamos como array $ret[end(array_keys($ret))] = array_merge(array($ret[end(array_keys($ret))]), array($param)); } } } } return $ret; }
public function destroy($kitTypeID) { // This Shall be fun! // We have to deconstruct the types based on the forign key dependencys // First iterate all the kits, for each kit remove all contents, // and then all bookings (and all booking details) // then finally we can remove the kit type and then all the logs for that // kit type. foreach (Kits::where('KitType', '=', $kitTypeID)->get() as $kit) { foreach (KitContents::where("KitID", '=', $kit->ID)->get() as $content) { KitContents::destroy($content->ID); } foreach (Booking::where("KitID", '=', $kit->ID)->get() as $booking) { foreach (BookingDetails::where("BookingID", '=', $booking->ID)->get() as $detail) { BookingDetails::destroy($detail->ID); } Booking::destroy($booking->ID); } Kits::destroy($kit->ID); } KitTypes::destroy($kitTypeID); // Do the logs last, as all the deletes will log the changes of deleting the bits. Logs::where('LogKey1', '=', $kitTypeID)->delete(); return "OK"; }
public static function boot() { parent::boot(); static::created(function ($record) { $kitTypeID = $record->KitType; $kitID = $record->ID; Logs::LogMsg(4, $kitTypeID, $kitID, null, "Created Kit: " . $record->Name); return true; }); static::updating(function ($record) { $kitTypeID = $record->KitType; $kitID = $record->ID; $dirty = $record->getDirty(); foreach ($dirty as $field => $newdata) { $olddata = $record->getOriginal($field); if ($olddata != $newdata) { Logs::LogMsg(5, $kitTypeID, $kitID, null, "Changed Kit field: " . $field . " From:" . $olddata . " To:" . $newdata); } } return true; }); static::deleting(function ($record) { $kitTypeID = $record->KitType; $kitID = $record->ID; Logs::LogMsg(6, $kitTypeID, $kitID, null, "Deleted Kit: " . $record->Name); return true; }); }
public static function boot() { parent::boot(); static::created(function ($record) { $kitTypeID = $record->kit->KitType; $kitID = $record->kit->ID; Logs::LogMsg(10, $kitTypeID, $kitID, $record->ID, "Added content: " . $record->Name); return true; }); static::updating(function ($record) { $kitTypeID = $record->kit->KitType; $kitID = $record->kit->ID; $dirty = $record->getDirty(); foreach ($dirty as $field => $newdata) { $olddata = $record->getOriginal($field); if ($olddata != $newdata) { Logs::LogMsg(11, $kitTypeID, $kitID, $record->ID, "Changed " . $field . " From:" . $olddata . " To:" . $newdata); } } return true; }); static::deleting(function ($record) { $kitTypeID = $record->kit->KitType; $kitID = $record->kit->ID; Logs::LogMsg(12, $kitTypeID, $kitID, $record->ID, "Removed Contents: " . $record->Name); return true; }); }
public function tearDown() { $classArr = array_slice(explode('\\', static::getClassName()), -1, 1); $className = $classArr[0]; $data = Tools::encoding($this->args, "utf-8", "gbk"); /** * @ 此步可以记录队列总共、每天、每月、每年处理的数量 * @ 2015/12/15 added */ # $redis = ""; # $key = "{$className}:nums"; # $dayKey = "{$className}:".date('Ymd')."nums"; # $monthKey = "{$className}:".date('Ym')."nums"; # $yearKey = "{$className}:".date('Y')."nums"; # # try { # $redis->incr($key); # $redis->incr($dayKey); # $redis->incr($monthKey); # $redis->incr($yearKey); # } catch(RedisException $e) { # Logs::logit(date('Y-m-d H:i:s')."\t".$e->getMessage(), "error".date('Ymd').".log"); # } # /** * 日志记录每条数据操作,后期可添加Cron定期清理 */ Logs::logit(date('Y-m-d H:i:s') . "\t" . $key . " inc 1"); Logs::logit(date('Y-m-d H:i:s') . "\n" . var_export($data['array'], true), $className . date('Ymd') . ".log"); }
public static function boot() { parent::boot(); static::created(function ($record) { $userName = ""; if (isset($record->UserID)) { $userName = User::find($record->UserID)->username; } else { $userName = $record->Email; } $primaryBooker = " as primary booker"; if (!$record->Booker) { $primaryBooker = " as secondary contact"; } Logs::LogMsg(18, $record->booking->kit->KitType, $record->booking->kit->ID, $record->booking->branch->ID, "Added user:"******" changed From:" . $olddata . " To:" . $newdata); } } return true; }); static::deleting(function ($record) { Logs::LogMsg(20, $record->booking->kit->KitType, $record->booking->kit->ID, $record->booking->branch->ID, "Detail deleted by:" . Auth::user()->username); return true; }); }
function change_status() { $id = intval(Url::get('id'), 0); $amount = intval(Url::get('amount'), 0); if ($amount == '' || $amount <= 0) { echo 'amount_null'; } else { $log = Logs::get_log($id); $str_change = array(); if (!empty($log)) { $str_change = unserialize($log['data']); } $value = array('status' => '00', 'amount' => $amount, 'description' => 'Giao dịch thành công.', 'pin' => $str_change['pin'], 'serial' => $str_change['serial'], 'type' => $str_change['type']); $value = serialize($value); $id = Logs::update_log($id, array('data' => $value)); if ($id) { $str_topup = array('uid' => $log['uid'], 'serial' => $str_change['serial'], 'pin' => $str_change['pin'], 'type' => $str_change['type'], 'created' => $log['origin_time'], 'price' => $amount); DB::insert('topup', $str_topup); $user = PersonalDB::get_account_byId($log['uid']); $new_coin = $user['coin'] + $amount; DB::update_id('account', array('coin' => $new_coin), $user['id']); } } exit; }
public static function escreverNoLogObjeto($texto, $titulo) { $handle = fopen(Logs::DirLogs() . "Log_" . date("Ymd") . ".log", "a"); fputs($handle, "" . date("Ymd His") . " - "); fputs($handle, $titulo . print_r($texto, true) . "\n", 9999999); fclose($handle); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $student = Student::find($id); if ($student == NULL) { throw new Exception('Invalid Student ID'); } $student->year = (int) substr($student->year, 2, 4); $student_category = StudentCategories::find($student->category); $student->category = $student_category->category; $student_branch = Branch::find($student->branch); $student->branch = $student_branch->branch; if ($student->rejected == 1) { unset($student->approved); unset($student->books_issued); $student->rejected = (bool) $student->rejected; return $student; } if ($student->approved == 0) { unset($student->rejected); unset($student->books_issued); $student->approved = (bool) $student->approved; return $student; } unset($student->rejected); unset($student->approved); $student_issued_books = Logs::select('book_issue_id', 'issued_at')->where('student_id', '=', $id)->orderBy('time_stamp', 'desc')->take($student->books_issued)->get(); foreach ($student_issued_books as $issued_book) { $issue = Issue::find($issued_book->book_issue_id); $book = Books::find($issue->book_id); $issued_book->name = $book->title; $issued_book->issued_at = date('d-M', $issued_book->issued_at); } $student->issued_books = $student_issued_books; return $student; }
static function get_instance() { if (self::$instance == NULL) { self::$instance = new logs(); } return self::$instance; }
public function index() { $user_id = Auth::user()->id; $breadcrumbs = Data_users::where('user_id', '=', $user_id)->first(); $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name; $logs = Logs::all(); return View::make('dashboard.logs.index', ['nombre' => $breadcrumbs_data, 'logs' => $logs]); }
public function run() { $faker = Faker::create(); Logs::truncate(); foreach (range(1, 500) as $index) { Logs::create(["ip" => $faker->localIpv4, "host" => $faker->domainName, "lastpage" => "", "last_visit" => $faker->dateTimeBetween($startDate = '-120 days', $endDate = 'now'), "created_at" => $faker->date($format = 'Y-m-d', $max = 'now') . ' ' . $faker->time($format = 'H:i:s', $max = 'now'), "updated_at" => $faker->date($format = 'Y-m-d', $max = 'now') . ' ' . $faker->time($format = 'H:i:s', $max = 'now'), "role_id" => $faker->numberBetween($min = 1, $max = 6), "data_id" => $faker->numberBetween($min = 1, $max = 11)]); } }
public static function getLogHandle() { $log = Logs::getInstance(); $logPath = \AppHelper::Instance()->config("LOG_PATH"); $log->init(BASEPATH . $logPath . "log.log"); $log->logInfo("返回日志句柄"); return $log; }
public function loadModel($id) { $model = Logs::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
private function _connect($config) { $port = isset($config["port"]) ? $config["port"] : null; $ret = new mysqli($config["host"], $config["user"], $config["password"], $config["database"], $port); if (!$ret) { Logs::stFatal("Can't connet to database"); } return $ret; }
/** * Logout */ public function processOut() { Logs::set(array('type' => 'LOG', 'message' => 'Logout: ' . _currentUser()->getLogin())); CopixAuth::getCurrentUser()->logout(array()); CopixEventNotifier::notify('logout', array('login' => CopixAuth::getCurrentUser()->getLogin())); CopixAuth::destroyCurrentUser(); CopixSession::destroyNamespace('default'); return _arRedirect(CopixRequest::get('auth_url_return', _url('||'))); }
public function getLogout() { $log = Logs::where('user_id', '=', Auth::user()->id)->orderBy('id', 'DESC')->first(); $log->logout = date('Y-m-d H:i:s', time()); $log->save(); Session::flash('success', 'Se ha cerrado sesión satisfactoriamente.'); Auth::logout(); return Redirect::to('administrador/login'); }
/** * Печать анкеты */ public function anketa() { Logs::write(Core::getInstance()->user, 'amt', null); if (!isset($_POST['anketa'])) { throw new Exception('No personal data'); } $data = $this->_prepareData($_POST['anketa']); $parsedData = $this->_parseData($data); $this->_sendEmail($parsedData); $this->renderJsonSuccess("Анкета успешно отправлена!"); }
public function __construct($array = null, $success = true) { if (!$success) { $this->exception = new SmsException($array); } else { if ($array) { Logs::warn('Constructor with JSON params in ' . get_class($this) . ' is deprecated, use Conversions utility class!'); Conversions::fillFromJSON($this, $array, !$success); } } }
public function display_logs() { $params = array(); if (isset($_GET['page'])) { $params['page'] = $_GET['page']; $this->template->page = $_GET['page']; } $this->template->logs = Logs::get($params); $this->template->pager = Logbox::paginate('Logs', $params, 'http://logbox.localhost/logs'); $this->template->display('logs.php'); }
public function __construct($arrayOrJson = null, $success = true) { // TODO: Remove this and use only the Conversions class if (!$success) { $this->exception = new SmsException($arrayOrJson); } else { if ($arrayOrJson) { Logs::warn('Constructor with JSON params in ' . get_class($this) . ' is deprecated, use Conversions utility class!'); Conversions::fillFromJSON($this, $arrayOrJson, !$success); } } }