示例#1
0
文件: Typeframe.php 项目: ssrsfs/blg
 /**
  * Log a user action to the database.
  * @param string $action.
  * @param string $fulldesc The full description of the event [optional].
  */
 public static function Log($action, $fulldesc = false)
 {
     if (!$fulldesc) {
         $fulldesc = $action;
     }
     // Also addin the source URL, as that may change and reveal important information.
     if (isset($_SERVER['HTTP_HOST'])) {
         $fulldesc .= "\n" . 'Source URL: ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         if (isset($_SERVER['HTTP_REFERER'])) {
             $fulldesc .= "\n" . 'Referrer URL: ' . $_SERVER['HTTP_REFERER'];
         }
     } else {
         $fulldesc .= "\nN/a";
     }
     $log = Model_Log::Create();
     $log['userid'] = Typeframe::User()->get('userid');
     $log['ipaddress'] = @$_SERVER['REMOTED_ADDR'];
     $log['package'] = Typeframe::CurrentPage() ? Typeframe::CurrentPage()->application()->package() : '';
     $log['application'] = Typeframe::CurrentPage() ? Typeframe::CurrentPage()->application()->name() : '';
     $log['action'] = $action;
     $log['logdate'] = Typeframe::Now();
     $log['fulldesc'] = $fulldesc;
     $log->save();
 }
示例#2
0
 /**
  * 记录系统日志
  * @param string $msg
  * @param bollean $constraint 是否强制插入
  */
 public static function addLog($msg = NULL, $constraint = FALSE)
 {
     static $isAdd = false;
     //单例,只插入一次
     if ($isAdd && $constraint == false) {
         return;
     }
     self::import('Model_Log');
     $modelLog = new Model_Log();
     $modelLog->add($msg, $constraint);
     $isAdd = true;
 }
示例#3
0
 /**
  * @param $user Model_User
  */
 protected function _notifyBadTags($user)
 {
     $username = $user->getUsername();
     $message = "User: {$username} \r\n\r\n";
     /** @var $tag Model_Tag */
     $i = 1;
     foreach ($this->_badTags as $tag) {
         $tagName = $tag->getTag();
         $subject = $tag->getSubject();
         $summary = $tag->getSummary($tag->getTagRecord());
         $message .= $i . ". {$tagName} ({$subject}) \r\n{$summary}\r\n\r\n";
         $i++;
     }
     $log = new Model_Log();
     $log->log("Notifying {$username} of bad tags");
     mail("*****@*****.**", "InsightEngine Alert for {$username}", $message, "From: cron@magemail.co");
     return $this;
 }
示例#4
0
文件: User.php 项目: tests1/zendcasts
 public function postSave(Doctrine_Event $event)
 {
     $log = new Model_Log();
     $log->message = "email address for '" . $this->username . "' changed to " . $this->email;
     $log->save();
 }
示例#5
0
 public function actionLog()
 {
     $users = $this->_getGlobalData('user');
     $users = Model::getTtwoArrConvertOneArr($users, 'Id', 'nick_name');
     $this->_modelLog = $this->_getGlobalData('Model_Log', 'object');
     $this->_loadCore('Help_SqlSearch');
     $helpSqlSearch = new Help_SqlSearch();
     $helpSqlSearch->set_tableName($this->_modelLog->tName());
     $selected = array();
     if ($_GET['user_id'] != '') {
         $helpSqlSearch->set_conditions("user_id={$_GET['user_id']}");
         $selected['user_id'] = $_GET['user_id'];
     }
     if ($_GET['detail'] != '') {
         if ($_GET['detail'] == 1) {
             $helpSqlSearch->set_conditions("msg is not null");
             $selected['detail'] = 1;
         } else {
             $helpSqlSearch->set_conditions("msg is null");
             $selected['detail'] = 0;
         }
     }
     if ($_GET['start_time'] && $_GET['end_time']) {
         $startTime = date('Ym', strtotime($_GET['start_time']));
         $endtime = date('Ym', strtotime($_GET['end_time']));
         if ($startTime != $endtime) {
             $this->_utilMsg->showMsg(Tools::getLang('DATE_ERROR', __CLASS__), -1, 2);
         }
         $this->_modelLog->setTableName("log_{$startTime}");
         $helpSqlSearch->set_tableName($this->_modelLog->tName());
         $startTime = strtotime($_GET['start_time']);
         $endtime = strtotime($_GET['end_time']);
         $helpSqlSearch->set_conditions("`time` between {$startTime} and {$endtime}");
         $selected['start_time'] = $_GET['start_time'];
         $selected['end_time'] = $_GET['end_time'];
     }
     if ($_GET['control']) {
         $helpSqlSearch->set_conditions("control='" . strtolower($_GET['control']) . "'");
         $selected['control'] = $_GET['control'];
     }
     if ($_GET['action']) {
         $helpSqlSearch->set_conditions("action='" . strtolower($_GET['action']) . "'");
         $selected['action'] = $_GET['action'];
     }
     if ($_GET['doaction']) {
         $helpSqlSearch->set_conditions("doaction='" . strtolower($_GET['doaction']) . "'");
         $selected['doaction'] = $_GET['doaction'];
     }
     $helpSqlSearch->setPageLimit($_GET['page']);
     $conditions = $helpSqlSearch->get_conditions();
     $sql = $helpSqlSearch->createSql();
     $dataList = $this->_modelLog->select($sql);
     if ($dataList) {
         $this->_loadCore('Help_Page');
         $helpPage = new Help_Page(array('total' => $this->_modelLog->findCount($conditions), 'perpage' => PAGE_SIZE));
         $this->_view->assign('pageBox', $helpPage->show());
         foreach ($dataList as &$list) {
             $list['word_user_id'] = $users[$list['user_id']];
             $list['time'] = date('Y-m-d H:i:s', $list['time']);
             $list['ip'] = long2ip($list['ip']);
         }
         $this->_view->assign('dataList', $dataList);
     }
     $this->_view->assign('selectDetal', Tools::getLang('SELECT_DETAIL', __CLASS__));
     $this->_view->assign('users', $users);
     $this->_view->assign('selected', $selected);
     $this->_utilMsg->createNavBar();
     $this->_view->display();
 }